-
Notifications
You must be signed in to change notification settings - Fork 27.3k
/
index.js
46 lines (40 loc) · 1.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import Link from "next/link";
import Head from "next/head";
import Title from "../../components/title";
import useI18n from "../../hooks/use-i18n";
import { languages, contentLanguageMap } from "../../lib/i18n";
const HomePage = () => {
const i18n = useI18n();
return (
<div>
<Head>
<meta
httpEquiv="content-language"
content={contentLanguageMap[i18n.activeLocale]}
/>
</Head>
<Title username="Peter" />
<h2>{i18n.t("intro.text")}</h2>
<h3>{i18n.t("intro.description")}</h3>
<div>Current locale: {i18n.activeLocale}</div>
<Link href="/[lng]" as="/de">
Use client-side routing to change language to 'de'
</Link>
</div>
);
};
export async function getStaticProps({ params }) {
const { default: lngDict = {} } = await import(
`../../locales/${params.lng}.json`
);
return {
props: { lng: params.lng, lngDict },
};
}
export async function getStaticPaths() {
return {
paths: languages.map((l) => ({ params: { lng: l } })),
fallback: false,
};
}
export default HomePage;