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> </button>
<script is:inline> <script is:inline>
const isDark = const applyTheme = () => {
localStorage.theme === 'dark' || const isDark =
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches); localStorage.theme === 'dark' ||
document.documentElement.classList.toggle('dark', isDark); (!('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>
<script> <script>