From 2cc596bdfaa96277bd62c3602e7789affd2c19bc Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 5 May 2026 23:51:32 +0100 Subject: [PATCH] fix: correct docs site interactions --- scripts/docs-site/assets.mjs | 2 +- scripts/docs-site/build.mjs | 2 +- scripts/docs-site/mdx-ish.mjs | 30 ++++++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/docs-site/assets.mjs b/scripts/docs-site/assets.mjs index 248e05cfb..fe38c5f0c 100644 --- a/scripts/docs-site/assets.mjs +++ b/scripts/docs-site/assets.mjs @@ -13,7 +13,7 @@ export function siteCss() { export function siteJs() { return ` -const root=document.documentElement;const saved=localStorage.getItem("theme");if(saved)root.dataset.theme=saved;document.querySelector("[data-theme]")?.addEventListener("click",()=>{const next=root.dataset.theme==="dark"?"light":"dark";root.dataset.theme=next;localStorage.setItem("theme",next)}); +const root=document.documentElement;const saved=localStorage.getItem("theme");if(saved)root.dataset.theme=saved;document.querySelector("[data-theme-toggle]")?.addEventListener("click",()=>{const next=root.dataset.theme==="dark"?"light":"dark";root.dataset.theme=next;localStorage.setItem("theme",next)}); const sidebar=document.querySelector(".sidebar");document.querySelector("[data-nav-toggle]")?.addEventListener("click",()=>sidebar?.classList.toggle("open"));document.querySelectorAll(".sidebar a").forEach(a=>a.addEventListener("click",()=>sidebar?.classList.remove("open"))); document.querySelector("[data-locale]")?.addEventListener("change",e=>{const url=e.target.selectedOptions[0]?.dataset.url;if(url)location.href=url}); const modal=document.querySelector(".search-modal");const input=document.querySelector("[data-search-input]");const results=document.querySelector("[data-search-results]");let pagefindReady; diff --git a/scripts/docs-site/build.mjs b/scripts/docs-site/build.mjs index 08033b242..e6a6ca329 100644 --- a/scripts/docs-site/build.mjs +++ b/scripts/docs-site/build.mjs @@ -173,7 +173,7 @@ function sidebar(page, nav, activeTab) { const groups = (nav.find((tab) => tab.title === activeTab) ?? nav[0])?.groups ?? []; return `"; if (kind === "cardSelf") return cardHtml(value, true); if (kind === "cardOpen") return cardHtml(value, false); - if (kind === "cardClose") return ""; + if (kind === "cardClose") return ""; if (kind === "stepOpen") return `
  • ${escapeHtml(parseAttrs(value).title ?? "Step")}

    `; if (kind === "stepClose") return "
  • "; if (kind === "tabOpen") return `

    ${escapeHtml(parseAttrs(value).title ?? "Tab")}

    `; @@ -111,8 +111,30 @@ function cardHtml(rawAttrs, selfClosing) { const href = attrs.href ?? "#"; const title = attrs.title ?? attrs.name ?? "Open"; const icon = attrs.icon ? `${escapeHtml(attrs.icon)}` : ""; - const end = selfClosing ? "" : ""; - return `${icon}${escapeHtml(title)}${end}`; + const end = selfClosing ? "" : ""; + return `${icon}
    ${escapeHtml(title)}${end}`; +} + +function dedentComponentChildren(markdown) { + let depth = 0; + return markdown + .split("\n") + .map((line) => { + const markerMatch = line.match(new RegExp(`^${markerPrefix}:([^:]+):`)); + if (markerMatch) { + if (markerMatch[1].endsWith("Close") || markerMatch[1] === "blockClose" || markerMatch[1] === "calloutClose") { + depth = Math.max(0, depth - 1); + } + const markerLine = line; + if (markerMatch[1].endsWith("Open") || markerMatch[1] === "blockOpen" || markerMatch[1] === "calloutOpen") { + depth += 1; + } + return markerLine; + } + if (depth <= 0 || !line.startsWith(" ")) return line; + return line.replace(new RegExp(`^ {1,${depth * 2}}`), ""); + }) + .join("\n"); } function parseAttrs(raw) {