initial commit
This commit is contained in:
commit
3c2fb32b3e
73 changed files with 22349 additions and 0 deletions
23
src/config/PreTheme.astro
Normal file
23
src/config/PreTheme.astro
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
|
||||
---
|
||||
|
||||
<script is:inline>
|
||||
function updateTheme() {
|
||||
if (
|
||||
localStorage.theme === "dark" ||
|
||||
(!("theme" in localStorage) &&
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches)
|
||||
) {
|
||||
document.documentElement.classList.add("dark");
|
||||
} else {
|
||||
document.documentElement.classList.remove("dark");
|
||||
}
|
||||
}
|
||||
|
||||
// Run on initial load
|
||||
updateTheme();
|
||||
|
||||
// Run on view transitions
|
||||
document.addEventListener("astro:after-swap", updateTheme);
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue