* Update Next.js and React versions in all packages * Replace onRedirect function with next/link in BillingSessionStatus, since it's no longer cached by default * Remove unused revalidatePath import in billing return page, since it's no longer cached by default * Add Turbopack module aliases to improve development server speed * Converted new Dynamic APIs to be Promise-based * Adjust mobile layout * Use ENABLE_REACT_COMPILER to enable the React Compiler in Next.js 15 * Report Errors using the new onRequestError hook
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import { cookies } from 'next/headers';
|
|
|
|
import { Toaster } from '@kit/ui/sonner';
|
|
import { cn } from '@kit/ui/utils';
|
|
|
|
import { RootProviders } from '~/components/root-providers';
|
|
import { heading, sans } from '~/lib/fonts';
|
|
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
|
import { generateRootMetadata } from '~/lib/root-metdata';
|
|
|
|
import '../styles/globals.css';
|
|
|
|
export default async function RootLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const { language } = await createI18nServerInstance();
|
|
const theme = await getTheme();
|
|
const className = getClassName(theme);
|
|
|
|
return (
|
|
<html lang={language} className={className}>
|
|
<body>
|
|
<RootProviders theme={theme} lang={language}>
|
|
{children}
|
|
</RootProviders>
|
|
|
|
<Toaster richColors={true} theme={theme} position="top-center" />
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|
|
|
|
function getClassName(theme?: string) {
|
|
const dark = theme === 'dark';
|
|
const light = !dark;
|
|
|
|
const font = [sans.variable, heading.variable].reduce<string[]>(
|
|
(acc, curr) => {
|
|
if (acc.includes(curr)) return acc;
|
|
|
|
return [...acc, curr];
|
|
},
|
|
[],
|
|
);
|
|
|
|
return cn('min-h-screen bg-background antialiased', ...font, {
|
|
dark,
|
|
light,
|
|
});
|
|
}
|
|
|
|
async function getTheme() {
|
|
const cookiesStore = await cookies();
|
|
return cookiesStore.get('theme')?.value as 'light' | 'dark' | 'system';
|
|
}
|
|
|
|
export const generateMetadata = generateRootMetadata;
|