mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 03:32:51 +02:00
fix: theme toggle error
This commit is contained in:
parent
c1017156da
commit
20fd3b65f3
1 changed files with 7 additions and 0 deletions
|
@ -20,6 +20,13 @@
|
||||||
document.startViewTransition(switchTheme)
|
document.startViewTransition(switchTheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync theme on page navigation
|
||||||
|
document.addEventListener('astro:after-swap', () => {
|
||||||
|
const theme = localStorage.getItem('theme')
|
||||||
|
document.documentElement.classList.toggle('dark', theme === 'dark')
|
||||||
|
themeToggle.setAttribute('aria-pressed', String(theme === 'dark'))
|
||||||
|
})
|
||||||
|
|
||||||
themeToggle.addEventListener('click', toggleTheme)
|
themeToggle.addEventListener('click', toggleTheme)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue