Port Docs-Viewer to slatehtml as the docs-viewer package.

Replace the classic DOM shell with slate widgets, markdown→slate rendering, and a CI index build that uses build-docs.cjs.
This commit is contained in:
2026-08-02 20:48:31 +10:00
parent 407ee6c0d3
commit 10e9f7ac2f
36 changed files with 3789 additions and 5474 deletions

24
src/markdown/decorate.js Normal file
View File

@@ -0,0 +1,24 @@
/**
* Light post-pass for marked HTML: wiki `?slug` links + lazy images.
* Content is trusted site markdown — no tag stripping.
*/
export function decorateHtml(html) {
if (!html) return "";
if (typeof document === "undefined") return String(html);
const tpl = document.createElement("template");
tpl.innerHTML = String(html);
for (const a of tpl.content.querySelectorAll("a[href]")) {
const href = a.getAttribute("href") || "";
if (href.startsWith("?")) a.setAttribute("data-internal", "true");
else if (href.startsWith("http")) {
a.setAttribute("target", "_blank");
a.setAttribute("rel", "noopener noreferrer");
}
}
for (const img of tpl.content.querySelectorAll("img:not([loading])")) {
img.setAttribute("loading", "lazy");
}
return tpl.innerHTML;
}