diff --git a/index.html b/index.html index c659646..8d2e817 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,7 @@ + diff --git a/public/theme-init.js b/public/theme-init.js new file mode 100644 index 0000000..862dc7a --- /dev/null +++ b/public/theme-init.js @@ -0,0 +1,7 @@ +const theme = localStorage.getItem("theme"); + +if (theme === "dark" || (!theme && window.matchMedia("(prefers-color-scheme: dark)").matches)) { + document.documentElement.classList.add("dark"); +} else { + document.documentElement.classList.remove("dark"); +}