- Theme Decoupling & Cleanup:
- Fully decoupled and vendored the Blowfish theme directly into root directories (layouts/,
assets/, static/, data/, i18n/).
- De-registered and cleaned up legacy Git submodules (themes/blowfish, themes/hugo-admonitions)
from the Git index to protect the build from upstream breakages.
- Configured .gitignore to ignore development preview symlinks (content, static,
config/_default/menus.en.toml), build folders (public/, resources/), and locks.
- TOC & Layout Fixes:
- Replaced the custom layouts/_default/single.html template with the Blowfish default to restore
native container widths and the side-by-side flex layout.
- Restored TOC to float on the right sidebar on desktop viewports and render inline on mobile
viewports.
- Fixed a parameter resolution bug in layouts/partials/toc.html by checking both .Site.Params.
smartTOC and .Site.Params.article.smartTOC (where it is defined in params.toml).
- Upgraded the TOC scrollspy JavaScript to target all '#TableOfContents' containers on the page,
enabling highlight tracking on both desktop and mobile layouts.
- Documentation Updates (README.md):
- Restored YAML front matter metadata block at the top.
- Added detailed notes on the CI/CD build process and Gitea runner deployment targets
(/srv/www/docs-public and /srv/www/docs-private).
- Added a categorized and sorted "Shortcodes Quick Reference" table at the top of the shortcodes
section (ordered by Custom, Hugo Default, and Blowfish).
- Documented custom shortcodes (Include, Screenshot, Raw HTML) and missing Hugo default
shortcodes (Highlight, Instagram, Param, Ref, Relref, Twitter, Vimeo, Youtube).
- Restructured headings to ensure all sub-shortcodes are H3, removed block break tags (<br/>),
and appended horizontal separators (---) after H2 sections.
93 lines
2.5 KiB
JavaScript
93 lines
2.5 KiB
JavaScript
(async () => {
|
|
const script = document.currentScript;
|
|
const repoURL = script?.getAttribute("data-repo-url");
|
|
const repoId = script?.getAttribute("data-repo-id");
|
|
|
|
if (!repoURL || !repoId) return;
|
|
if (repoId.startsWith("forgejo")) {
|
|
console.log(
|
|
"fetch-repo.js: Forgejo server blocks cross-origin requests. Live JavaScript updates are not supported.",
|
|
);
|
|
return;
|
|
}
|
|
|
|
const platforms = {
|
|
github: {
|
|
full_name: "full_name",
|
|
description: "description",
|
|
stargazers_count: "stargazers",
|
|
forks: "forks",
|
|
},
|
|
gitlab: {
|
|
name_with_namespace: "name_with_namespace",
|
|
description: "description",
|
|
star_count: "star_count",
|
|
forks_count: "forks_count",
|
|
},
|
|
gitea: {
|
|
full_name: "full_name",
|
|
description: "description",
|
|
stars_count: "stars_count",
|
|
forks_count: "forks_count",
|
|
},
|
|
codeberg: {
|
|
full_name: "full_name",
|
|
description: "description",
|
|
stars_count: "stars_count",
|
|
forks_count: "forks_count",
|
|
},
|
|
forgejo: {
|
|
full_name: "full_name",
|
|
description: "description",
|
|
stars_count: "stars_count",
|
|
forks_count: "forks_count",
|
|
},
|
|
huggingface: {
|
|
description: "description",
|
|
likes: "likes",
|
|
downloads: "downloads",
|
|
},
|
|
};
|
|
|
|
const processors = {
|
|
huggingface: {
|
|
description: (value) => value?.replace(/Dataset Card for .+?\s+Dataset Summary\s+/, "").trim() || value,
|
|
},
|
|
};
|
|
|
|
const platform = Object.keys(platforms).find((p) => repoId.startsWith(p)) || "github";
|
|
const mapping = platforms[platform];
|
|
|
|
try {
|
|
const response = await fetch(repoURL, {
|
|
headers: { "User-agent": "Mozilla/4.0 Custom User Agent" },
|
|
});
|
|
const data = await response.json();
|
|
|
|
if (!response.ok) {
|
|
console.error(`fetch-repo.js: HTTP Error: ${response.status} ${response.statusText}`);
|
|
return;
|
|
}
|
|
|
|
if (!data || typeof data !== "object") {
|
|
console.error("fetch-repo.js: Invalid or empty data received from remote");
|
|
return;
|
|
}
|
|
|
|
Object.entries(mapping).forEach(([dataField, elementSuffix]) => {
|
|
const element = document.getElementById(`${repoId}-${elementSuffix}`);
|
|
if (element) {
|
|
let value = data[dataField];
|
|
if (processors[platform]?.[dataField]) {
|
|
value = processors[platform][dataField](value);
|
|
}
|
|
if (value != null && value !== "") {
|
|
element.innerHTML = value;
|
|
}
|
|
}
|
|
});
|
|
} catch (error) {
|
|
console.error(`fetch-repo.js: ${error}`);
|
|
}
|
|
})();
|