Files
Hugo/layouts/_partials/custom/head-end.html
T

69 lines
2.3 KiB
HTML

<!-- Custom fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap"
rel="stylesheet"
/>
<!-- Expand sidebar tree by default -->
<script>
document.addEventListener("DOMContentLoaded", function () {
document
.querySelectorAll(".hextra-sidebar-collapsible-button")
.forEach(function (btn) {
var li = btn.closest("li");
if (li) li.classList.add("open");
});
});
</script>
<!-- Mermaid config + viewBox fix -->
<script>
(function () {
function patch() {
if (typeof mermaid === "undefined") return setTimeout(patch, 50);
var orig = mermaid.initialize;
mermaid.initialize = function (cfg) {
cfg = cfg || {};
cfg.flowchart = cfg.flowchart || {};
cfg.flowchart.useMaxWidth = true;
cfg.flowchart.wrappingWidth = 180;
cfg.theme = "neutral";
return orig.call(this, cfg);
};
}
patch();
// Fix oversized viewBox on flowcharts
function fixViewBox() {
document.querySelectorAll(".mermaid svg").forEach(function (svg) {
var vb = svg.getAttribute("viewBox");
if (!vb) return;
var p = vb.split(" ").map(Number);
if (p.length !== 4) return;
var h = p[3],
w = p[2];
if (h < 600 && w < 800) return;
var g = svg.querySelector("g");
if (!g) return;
var bb = g.getBBox();
if (bb.width === 0 && bb.height === 0)
return setTimeout(fixViewBox, 200);
var pad = 20;
svg.setAttribute(
"viewBox",
[
bb.x - pad,
bb.y - pad,
bb.width + pad * 2,
bb.height + pad * 2,
].join(" "),
);
});
}
setTimeout(fixViewBox, 600);
setTimeout(fixViewBox, 1200);
})();
</script>