mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-29 05:46:56 +01:00
12 lines
396 B
JavaScript
12 lines
396 B
JavaScript
function loadPreferredTheme() {
|
|
const preferredTheme = localStorage.getItem("pref-theme");
|
|
const isDarkTheme = document.body.classList.contains("dark");
|
|
|
|
if (preferredTheme === "light" && isDarkTheme) {
|
|
document.body.classList.remove('dark')
|
|
} else if (preferredTheme === "dark" && !isDarkTheme) {
|
|
document.body.classList.add('dark')
|
|
}
|
|
}
|
|
|
|
loadPreferredTheme(); |