color pref persistence
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user