Consolidate socials on index and add View Transitions API support
This commit is contained in:
parent
580cd2da26
commit
483f406037
23 changed files with 493 additions and 458 deletions
|
|
@ -1,13 +1,15 @@
|
|||
---
|
||||
import DarkModeInline from "./AutoDarkMode.astro";
|
||||
import DarkModeScriptInline from "./DarkModeScriptInline.astro";
|
||||
---
|
||||
|
||||
<DarkModeInline />
|
||||
<DarkModeScriptInline />
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
let colorScheme = localStorage.getItem("colorScheme");
|
||||
if (colorScheme == null || colorScheme === "auto") {
|
||||
import { ENABLE_VIEW_TRANSITIONS } from "astro:env/client";
|
||||
|
||||
const colorSchemeSetup = () => {
|
||||
let colorScheme = localStorage.colorScheme;
|
||||
if (!colorScheme || colorScheme === "auto") {
|
||||
colorScheme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||
}
|
||||
document.querySelectorAll<HTMLElementTagNameMap["button"]>("button[data-dark-mode]").forEach((button) => {
|
||||
|
|
@ -23,8 +25,13 @@ import DarkModeInline from "./AutoDarkMode.astro";
|
|||
colorScheme = "dark";
|
||||
document.body.classList.add("dark");
|
||||
}
|
||||
localStorage.setItem("colorScheme", colorScheme);
|
||||
localStorage.colorScheme = colorScheme;
|
||||
});
|
||||
});
|
||||
})();
|
||||
};
|
||||
if (ENABLE_VIEW_TRANSITIONS) {
|
||||
document.addEventListener("astro:page-load", colorSchemeSetup);
|
||||
} else {
|
||||
colorSchemeSetup();
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue