mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Iterated with translations
This commit is contained in:
68
app/[locale]/layout.tsx
Normal file
68
app/[locale]/layout.tsx
Normal file
@@ -0,0 +1,68 @@
|
||||
import Footer from 'components/layout/footer';
|
||||
import Header from 'components/layout/header';
|
||||
import { NextIntlClientProvider } from 'next-intl';
|
||||
import { Inter } from 'next/font/google';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { ReactNode } from 'react';
|
||||
import './globals.css';
|
||||
|
||||
const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env;
|
||||
|
||||
export const metadata = {
|
||||
title: {
|
||||
default: SITE_NAME,
|
||||
template: `%s | ${SITE_NAME}`
|
||||
},
|
||||
robots: {
|
||||
follow: true,
|
||||
index: true
|
||||
},
|
||||
...(TWITTER_CREATOR &&
|
||||
TWITTER_SITE && {
|
||||
twitter: {
|
||||
card: 'summary_large_image',
|
||||
creator: TWITTER_CREATOR,
|
||||
site: TWITTER_SITE
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
const inter = Inter({
|
||||
subsets: ['latin'],
|
||||
display: 'swap',
|
||||
variable: '--font-inter'
|
||||
});
|
||||
|
||||
export function generateStaticParams() {
|
||||
return [{locale: 'sv'}, {locale: 'en'}, {locale: 'nn'}];
|
||||
}
|
||||
|
||||
interface LocaleLayoutProps {
|
||||
children: ReactNode
|
||||
params: {
|
||||
locale: string
|
||||
}
|
||||
}
|
||||
|
||||
export default async function LocaleLayout({children, params: {locale}}: LocaleLayoutProps) {
|
||||
let messages;
|
||||
try {
|
||||
messages = (await import(`../../messages/${locale}.json`)).default;
|
||||
} catch (error) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<html lang={locale} className={inter.variable}>
|
||||
<body className="flex flex-col min-h-screen">
|
||||
<NextIntlClientProvider locale={locale} messages={messages}>
|
||||
<Header />
|
||||
<main className="flex-1">{children}</main>
|
||||
<Footer />
|
||||
</NextIntlClientProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user