fix: run theme on page swap

This commit is contained in:
2026-02-15 00:05:16 -06:00
parent 47a637353c
commit c4be4653be

View File

@@ -43,10 +43,16 @@
</button>
<script is:inline>
const isDark =
localStorage.theme === 'dark' ||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches);
document.documentElement.classList.toggle('dark', isDark);
const applyTheme = () => {
const isDark =
localStorage.theme === 'dark' ||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches);
document.documentElement.classList.toggle('dark', isDark);
};
applyTheme();
document.addEventListener('astro:after-swap', applyTheme);
</script>
<script>