Files
2026-03-11 22:55:36 -05:00

59 lines
1.3 KiB
TypeScript

import type { Metadata, Viewport } from "next";
import "@fontsource-variable/geist";
import "@fontsource-variable/geist-mono";
import "./globals.css";
import { ThemeProvider } from "./context/ThemeContext";
import { getThemeConfig } from "@/config";
export const viewport: Viewport = {
width: "device-width",
initialScale: 1,
viewportFit: "cover",
};
export const metadata: Metadata = (() => {
const theme = getThemeConfig();
return {
title: theme.meta.title,
description: theme.meta.description,
};
})();
function ThemeScript() {
return (
<script
dangerouslySetInnerHTML={{
__html: `
(function() {
try {
var theme = localStorage.getItem('theme');
if (theme === 'dark' || (!theme && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
} catch (e) {}
})();
`,
}}
/>
);
}
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="zh-CN" suppressHydrationWarning>
<body
className="antialiased font-sans"
>
<ThemeScript />
<ThemeProvider>{children}</ThemeProvider>
</body>
</html>
);
}