theme-scheme.js 338 B

123456789
  1. let theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'light'
  2. if (theme === 'system') {
  3. if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  4. theme = 'dark'
  5. } else {
  6. theme = 'light'
  7. }
  8. }
  9. document.documentElement.setAttribute('data-theme', theme)