misc
This commit is contained in:
@@ -5,6 +5,15 @@
|
||||
window.toggleTheme = () => {
|
||||
const currentTheme = document.documentElement.getAttribute("data-theme");
|
||||
const newTheme = currentTheme === "dark" ? "light" : "dark";
|
||||
|
||||
// Toggle the dark class for Tailwind
|
||||
if (newTheme === "dark") {
|
||||
document.documentElement.classList.add("dark");
|
||||
} else {
|
||||
document.documentElement.classList.remove("dark");
|
||||
}
|
||||
|
||||
// Dispatch event for astro-themes and other listeners
|
||||
document.dispatchEvent(new CustomEvent("set-theme", { detail: newTheme }));
|
||||
};
|
||||
|
||||
@@ -80,5 +89,7 @@
|
||||
ready();
|
||||
}
|
||||
|
||||
// Support both original and obfuscated event names
|
||||
document.addEventListener("astro:page-load", initMobileMenu);
|
||||
document.addEventListener("c:ready", initMobileMenu);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user