mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-15 19:22:52 +02:00
fix: theme toggle error
This commit is contained in:
parent
a8c56b6e8a
commit
8962f2613d
1 changed files with 8 additions and 0 deletions
|
@ -20,7 +20,15 @@
|
|||
document.startViewTransition(switchTheme)
|
||||
}
|
||||
|
||||
// Synchronize theme status
|
||||
function syncTheme() {
|
||||
const theme = localStorage.getItem('theme')
|
||||
document.documentElement.classList.toggle('dark', theme === 'dark')
|
||||
themeToggle.setAttribute('aria-pressed', String(theme === 'dark'))
|
||||
}
|
||||
|
||||
themeToggle.addEventListener('click', toggleTheme)
|
||||
document.addEventListener('astro:after-swap', syncTheme)
|
||||
</script>
|
||||
|
||||
<button
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue