hugo-toha/assets/scripts/core/theme-scheme.js
2024-12-27 14:10:06 -08:00

9 lines
336 B
JavaScript

let theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'dark'
if (theme === 'system') {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
theme = 'dark'
} else {
theme = 'dark'
}
}
document.documentElement.setAttribute('data-theme', theme)