mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-11 12:11:45 +00:00
- Linting/format - Replace ESLint/Prettier with Biome; remove old configs; add `biome.json`; update scripts - Tailwind-friendly `.stylelintrc.yaml`; Stylelint and Biome pass - Enable Biome across `modules/**`; prune legacy JS globals; ignore oversized `devicon.json` - Code fixes - `hb-theme.js`: avoid assignment-in-expressions; clearer dataset updates - `hugoblox-slides.js`: fix inner var scope (var → let); apply formatting - CI/CD - Split lint/build workflows; add path filters; Node via Corepack (pnpm from package.json) - Hugo pinned to env `HUGO_VERSION`; add consistency check vs `starters/academic-cv/hugoblox.yaml` - Nightly starters matrix build (academic-cv, landing-page); CodeQL weekly; resource caches - Workflows/Community - Greeter: switch to `pull_request_target`; add Contributor Guide to PR message - PR labeler for path-based labels - Repo policies/docs - `CODEOWNERS` for `@gcushen` - `SECURITY.md`, `SUPPORT.md` - Documented branch protection in `.github/settings.yml` - Move `CODE_OF_CONDUCT.md` to `.github/` - docs(zh): update `README.zh.md` translation Notes: - pnpm is sourced from `package.json: packageManager` via Corepack; no hard-coded pnpm versions in CI.
55 lines
1.7 KiB
JavaScript
55 lines
1.7 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", function () {
|
|
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]);
|
|
}
|
|
});
|
|
});
|
|
}
|