59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import type { Metadata } from "next";
|
||
import { Geist, Geist_Mono } from "next/font/google";
|
||
import "./globals.css";
|
||
import { ThemeProvider } from "./context/ThemeContext";
|
||
|
||
const geistSans = Geist({
|
||
variable: "--font-geist-sans",
|
||
subsets: ["latin"],
|
||
});
|
||
|
||
const geistMono = Geist_Mono({
|
||
variable: "--font-geist-mono",
|
||
subsets: ["latin"],
|
||
});
|
||
|
||
export const metadata: Metadata = {
|
||
title: "数字游民指南 | Digital Nomad Guide",
|
||
description:
|
||
"从零开始,7天开启你的数字游民生活。远程工作、地点自由、技能变现 —— 一站式数字游民资源平台。",
|
||
};
|
||
|
||
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" suppressHydrationError>
|
||
<body
|
||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||
>
|
||
<ThemeScript />
|
||
<ThemeProvider>{children}</ThemeProvider>
|
||
</body>
|
||
</html>
|
||
);
|
||
}
|