color pref persistence

This commit is contained in:
Michael Freno
2025-12-31 01:44:00 -05:00
parent 28cabb8d16
commit 81b7c6e322
2 changed files with 57 additions and 4 deletions

View File

@@ -12,6 +12,17 @@ export default createHandler(() => (
content="width=device-width, initial-scale=1, maximum-scale=1"
/>
<link rel="icon" href="/favicon.ico" />
<script>
{`
(function() {
const STORAGE_KEY = 'theme-override';
const stored = localStorage.getItem(STORAGE_KEY);
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const isDark = stored !== null ? stored === 'dark' : systemDark;
document.documentElement.classList.add(isDark ? 'dark' : 'light');
})();
`}
</script>
{assets}
</head>
<body>