31 lines
919 B
Text
31 lines
919 B
Text
---
|
|
|
|
---
|
|
|
|
<script is:inline data-astro-rerun>
|
|
(function () {
|
|
var colorScheme = localStorage.getItem("colorScheme");
|
|
if (colorScheme == null || colorScheme === "auto") {
|
|
localStorage.setItem("colorScheme", "auto");
|
|
colorScheme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
}
|
|
const bodyClassList = document.body.classList;
|
|
if (colorScheme === "dark") {
|
|
bodyClassList.add("dark");
|
|
}
|
|
|
|
document.querySelectorAll("button[data-dark-mode]").forEach(function (button) {
|
|
button.addEventListener("click", function (e) {
|
|
e.preventDefault();
|
|
if (colorScheme === "dark") {
|
|
colorScheme = "light";
|
|
bodyClassList.remove("dark");
|
|
} else {
|
|
colorScheme = "dark";
|
|
bodyClassList.add("dark");
|
|
}
|
|
localStorage.setItem("colorScheme", colorScheme);
|
|
});
|
|
});
|
|
})();
|
|
</script>
|