64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import "@repo/config-tailwind/styles.css"
|
|
import { VERSION } from "@repo/constants"
|
|
import type { Locale, LocaleProps } from "@repo/i18n/config"
|
|
import { LOCALES } from "@repo/i18n/config"
|
|
import { Footer } from "@repo/ui/Footer"
|
|
import { Header } from "@repo/ui/Header"
|
|
import { ThemeProvider } from "@repo/ui/Header/SwitchTheme"
|
|
import type { Metadata } from "next"
|
|
import { NextIntlClientProvider } from "next-intl"
|
|
import {
|
|
getMessages,
|
|
getTranslations,
|
|
unstable_setRequestLocale,
|
|
} from "next-intl/server"
|
|
|
|
export const generateMetadata = async ({
|
|
params,
|
|
}: LocaleProps): Promise<Metadata> => {
|
|
const t = await getTranslations({ locale: params.locale })
|
|
return {
|
|
title: t("meta.title"),
|
|
description: t("meta.description"),
|
|
}
|
|
}
|
|
|
|
export const generateStaticParams = (): Array<{ locale: Locale }> => {
|
|
return LOCALES.map((locale) => {
|
|
return {
|
|
locale,
|
|
}
|
|
})
|
|
}
|
|
|
|
interface LocaleLayoutProps extends React.PropsWithChildren {
|
|
params: {
|
|
locale: Locale
|
|
}
|
|
}
|
|
|
|
const LocaleLayout: React.FC<LocaleLayoutProps> = async (props) => {
|
|
const { children, params } = props
|
|
|
|
// Enable static rendering
|
|
unstable_setRequestLocale(params.locale)
|
|
|
|
const messages = await getMessages()
|
|
|
|
return (
|
|
<html lang={params.locale} suppressHydrationWarning>
|
|
<body>
|
|
<ThemeProvider>
|
|
<NextIntlClientProvider messages={messages}>
|
|
<Header />
|
|
{children}
|
|
<Footer version={VERSION} />
|
|
</NextIntlClientProvider>
|
|
</ThemeProvider>
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
|
|
export default LocaleLayout
|