Files
2026-03-11 23:17:16 -05:00

52 lines
1.1 KiB
TypeScript

import type { Metadata, Viewport } from "next";
import "./globals.css";
import { ThemeProvider } from "./context/ThemeContext";
import { getSiteConfig } from "@/config";
export const viewport: Viewport = {
width: "device-width",
initialScale: 1,
viewportFit: "cover",
};
export const metadata: Metadata = {
title: getSiteConfig().meta.title,
description: getSiteConfig().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">
<ThemeScript />
<ThemeProvider>{children}</ThemeProvider>
</body>
</html>
);
}