Fix: don't assume that light mode is active on initial theme switch

This commit is contained in:
Philipp Oppermann
2021-10-17 16:34:59 +02:00
parent 5ff1aab7b5
commit 0fa31a0e15

View File

@@ -68,8 +68,10 @@ function toc_scroll_position(container) {
function toggle_lights() {
if (document.documentElement.getAttribute("data-theme") === "dark") {
set_theme("light")
} else {
} else if (document.documentElement.getAttribute("data-theme") === "light") {
set_theme("dark")
} else {
set_theme(window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "dark")
}
}