-
-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathlayout.tsx
64 lines (56 loc) · 1.49 KB
/
layout.tsx
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import {Metadata} from 'next';
import {NextIntlClientProvider, useLocale} from 'next-intl';
import {
getFormatter,
getNow,
getTimeZone,
getTranslations
} from 'next-intl/server';
import {ReactNode} from 'react';
import {Inter} from 'next/font/google';
import {routing} from '@/i18n/routing';
import Navigation from '../../components/Navigation';
const inter = Inter({subsets: ['latin']});
export async function generateStaticParams() {
return routing.locales.map((locale) => ({locale}));
}
export const dynamicParams = false;
export async function generateMetadata(): Promise<Metadata> {
const t = await getTranslations('LocaleLayout');
const formatter = await getFormatter();
const now = await getNow();
const timeZone = await getTimeZone();
return {
metadataBase: new URL('http://localhost:3000'),
title: t('title'),
description: t('description'),
other: {
currentYear: formatter.dateTime(now, {year: 'numeric'}),
timeZone
}
};
}
type Props = {
children: ReactNode;
};
export default function LocaleLayout({children}: Props) {
const locale = useLocale();
return (
<html className={inter.className} lang={locale}>
<body>
<div
style={{
padding: 24,
fontFamily: 'system-ui, sans-serif',
lineHeight: 1.5
}}
>
<NextIntlClientProvider>
<Navigation />
{children}
</NextIntlClientProvider>
</div>
</body>
</html>
);
}