diff --git a/static/light-toggle.js b/static/light-toggle.js index 06260d3..2023d32 100644 --- a/static/light-toggle.js +++ b/static/light-toggle.js @@ -1,5 +1,12 @@ function themeToggle() { - const oldValue = localStorage.getItem('theme'); + let oldValue = localStorage.getItem('theme'); + if (!oldValue) { + oldValue = 'light'; + if (window.matchMedia('(prefers-color-scheme: dark)').matches) { + oldValue = 'dark'; + } + } + let newValue; if (oldValue == 'light') { newValue = 'dark';