Add Zola templates and browser-tested site scaffold
This commit is contained in:
parent
fd5fc944e6
commit
a33673243e
1 changed files with 2114 additions and 0 deletions
24
static/theme.js
Normal file
24
static/theme.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
const mode = localStorage.getItem("theme") || "auto";
|
||||
document.documentElement.dataset.theme = mode;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const button = document.querySelector("#theme");
|
||||
const label = () =>
|
||||
button.setAttribute(
|
||||
"aria-label",
|
||||
`Theme: ${document.documentElement.dataset.theme}. Change theme`,
|
||||
);
|
||||
label();
|
||||
|
||||
button.addEventListener("click", () => {
|
||||
const modes = ["auto", "light", "dark"];
|
||||
const next =
|
||||
modes[
|
||||
(modes.indexOf(document.documentElement.dataset.theme) + 1) %
|
||||
modes.length
|
||||
];
|
||||
document.documentElement.dataset.theme = next;
|
||||
localStorage.setItem("theme", next);
|
||||
label();
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue