Files
George Cushen f4280ddb1c refactor: rename modules and update migration docs
BREAKING CHANGE
Module paths moved to `github.com/HugoBlox/kit` with new names:
- core `blox-tailwind` → `blox`
- analytics → `analytics`
- netlify → `integrations/netlify`
- slides (reveal) → `slides`
Update go.mod, module.yaml/params, scripts, tests, and v0.11 migration guide accordingly.
2026-01-02 20:59:48 +00:00

46 lines
1.6 KiB
JavaScript

// Hugo Blox JS Global Init (CSP-friendly)
export function initTheme() {
const root = document.documentElement;
const defaultTheme = root.dataset.wcThemeDefault;
const setDark = () => {
root.classList.add("dark");
root.style.colorScheme = "dark";
};
const setLight = () => {
root.classList.remove("dark");
root.style.colorScheme = "light";
};
if ("wc-color-theme" in localStorage) {
localStorage.getItem("wc-color-theme") === "dark" ? setDark() : setLight();
} else {
if (defaultTheme === "dark") setDark();
else if (defaultTheme === "light") setLight();
else if (defaultTheme === "system") {
window.matchMedia("(prefers-color-scheme: dark)").matches ? setDark() : setLight();
}
}
}
export function applyHugoStyleFixes() {
document.addEventListener("DOMContentLoaded", () => {
const checkboxes = document.querySelectorAll("li input[type='checkbox'][disabled]");
checkboxes.forEach((e) => {
const parent = e.parentElement?.parentElement;
if (parent) parent.classList.add("task-list");
});
const liNodes = document.querySelectorAll(".task-list li");
liNodes.forEach((nodes) => {
const textNodes = Array.from(nodes.childNodes).filter((node) => node.nodeType === 3 && node.textContent && node.textContent.trim().length > 1);
if (textNodes.length > 0) {
const span = document.createElement("label");
textNodes[0].after(span);
const input = nodes.querySelector("input[type='checkbox']");
if (input) span.appendChild(input);
span.appendChild(textNodes[0]);
}
});
});
}