This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
wikipedia-game-solver/apps/website/app/[locale]/layout.tsx
Théo LUDWIG 3ae6d2fac3
Some checks failed
Chromatic / chromatic (push) Failing after 42s
CI / ci (push) Successful in 2m44s
CI / commitlint (push) Successful in 14s
chore: initial commit
2024-07-24 12:35:33 +02:00

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