Skip to content

Commit b497f5f

Browse files
committed
feat(theme): implement theme toggle and improve color scheme handling
1 parent c6e0be7 commit b497f5f

3 files changed

Lines changed: 149 additions & 61 deletions

File tree

website/src/layouts/Layout.astro

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ const description = "黑鸦 · 标题风格生成器 — 流量密码,一键
4040
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap"
4141
rel="stylesheet"
4242
/>
43+
44+
<!-- Prevent FOUC: set data-theme before first paint -->
45+
<script is:inline>
46+
(function(){var t=localStorage.getItem("theme")||(window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.setAttribute("data-theme",t);})();
47+
</script>
4348
</head>
44-
<body class="font-sans bg-black text-foreground leading-relaxed antialiased min-h-screen overflow-x-hidden">
49+
<body class="font-sans bg-bg text-foreground leading-relaxed antialiased min-h-screen overflow-x-hidden">
4550
<a href="#main-content" class="skip-link">跳转到主要内容</a>
4651
<slot />
4752
</body>

0 commit comments

Comments
 (0)