/** * 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; }