This commit is contained in:
Henrik Larsson
2023-08-08 11:46:46 +02:00
parent 6527974989
commit 3e513eaf99
27 changed files with 449 additions and 760 deletions

View File

@@ -1,10 +1,9 @@
import Footer from 'components/layout/footer/footer';
import Header from 'components/layout/header/header';
import { NextIntlClientProvider } from 'next-intl';
import { useLocale } from 'next-intl';
import { Inter } from 'next/font/google';
import { notFound } from 'next/navigation';
import { ReactNode } from 'react';
import { supportedLanguages } from '../../i18n-config';
import './globals.css';
export const metadata = {
@@ -33,34 +32,30 @@ const inter = Inter({
variable: '--font-inter'
});
export function generateStaticParams() {
return supportedLanguages.locales.map((locale) => ({ locale: locale.id }));
}
// export function generateStaticParams() {
// return supportedLanguages.locales.map((locale) => ({ locale: locale.id }));
// }
interface LocaleLayoutProps {
export default function LocaleLayout({
children,
params
}: {
children: ReactNode;
params: {
locale: string;
};
}
params: { locale: string };
}) {
const locale = useLocale();
export default async function LocaleLayout({ children, params: { locale } }: LocaleLayoutProps) {
let messages;
try {
messages = (await import(`../../messages/${locale}.json`)).default;
} catch (error) {
// Show a 404 error if the user requests an unknown locale
if (params.locale !== locale) {
notFound();
}
return (
<html lang={locale} className={inter.variable}>
<body className="flex min-h-screen flex-col">
<NextIntlClientProvider locale={locale} messages={messages}>
<Header />
<main className="flex-1">{children}</main>
<Footer />
</NextIntlClientProvider>
<Header />
<main className="flex-1">{children}</main>
<Footer />
</body>
</html>
);