Content fetching in the marketing section has been refactored to utilize the Next.js cache, which significantly improves performance. The date format of publishedAt has been updated to be more consistent across files. Code related to CSRF token, fonts, and metadata has been refactored into separate files for easier maintenance and readability.
61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
import Head from 'next/head';
|
|
import { cookies } from 'next/headers';
|
|
|
|
import { Toaster } from '@kit/ui/sonner';
|
|
import { cn } from '@kit/ui/utils';
|
|
|
|
import { CsrfTokenMeta } from '~/components/csrf-token-meta';
|
|
import { RootProviders } from '~/components/root-providers';
|
|
import { heading, sans } from '~/lib/fonts';
|
|
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
|
import { rootMetadata } from '~/lib/root-metdata';
|
|
|
|
import '../styles/globals.css';
|
|
|
|
export default async function RootLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const { language } = await createI18nServerInstance();
|
|
const theme = getTheme();
|
|
const className = getClassName(theme);
|
|
|
|
return (
|
|
<html lang={language} className={className}>
|
|
<Head>
|
|
<CsrfTokenMeta />
|
|
</Head>
|
|
|
|
<body>
|
|
<RootProviders theme={theme} lang={language}>
|
|
{children}
|
|
</RootProviders>
|
|
|
|
<Toaster richColors={false} />
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|
|
|
|
function getClassName(theme?: string) {
|
|
const dark = theme === 'dark';
|
|
const light = !dark;
|
|
|
|
return cn(
|
|
'min-h-screen bg-background antialiased',
|
|
sans.variable,
|
|
heading.variable,
|
|
{
|
|
dark,
|
|
light,
|
|
},
|
|
);
|
|
}
|
|
|
|
function getTheme() {
|
|
return cookies().get('theme')?.value;
|
|
}
|
|
|
|
export const metadata = rootMetadata;
|