Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,6 @@ const alternates = [
</script>

<ClientRouter />

<script is:inline>
const getThemePreference = () => {
if (typeof localStorage !== 'undefined' && localStorage.getItem('theme')) {
return localStorage.getItem('theme')
}
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
const isDark = getThemePreference() === 'dark'
document.documentElement.classList[isDark ? 'add' : 'remove']('dark')
document.documentElement.classList[!isDark ? 'add' : 'remove']('light')

if (typeof localStorage !== 'undefined') {
const observer = new MutationObserver(() => {
const isDark = document.documentElement.classList.contains('dark')
localStorage.setItem('theme', isDark ? 'dark' : 'light')
})
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] })
}
</script>
</head>

<body
Expand Down
Loading