fix img src path, add theme toggle button
All checks were successful
/ build (push) Successful in 10s

This commit is contained in:
kritzl 2025-02-17 00:32:34 +01:00
commit f3b5be3c50
Signed by: kritzl
SSH key fingerprint: SHA256:5BmINP9VjZWaUk5Z+2CTut1KFhwLtd0ZynMekKbtViM
10 changed files with 181 additions and 126 deletions

View file

@ -1,3 +1,27 @@
document.querySelector('nav > button').addEventListener('click', (e) => {
document.querySelector('nav').classList.toggle('visible');
})
})
function applyTheme(theme){
const html = document.querySelector('html')
document.cookie = `theme=${theme}; expires=; SameSite=Strict; Secure`
html.classList.remove('dark', 'light')
html.classList.add(theme)
}
document.querySelectorAll('.toggleTheme').forEach(
element => element.addEventListener('click', (e) => {
const newTheme = element.dataset.theme;
applyTheme(newTheme);
}
)
);
const themeFromCookie = document.cookie
.split("; ")
.find((row) => row.startsWith("theme="))
?.split("=")[1];
if (themeFromCookie) {
applyTheme(themeFromCookie)
}