export function normalizeDocPath(docPath) { let p = String(docPath || "").trim(); p = p.replaceAll("\\", "/"); p = p.replace(/^\/+/, ""); p = p.replace(/\.\.\//g, ""); if (p === "" || p.endsWith("/")) p += "index"; if (!p.endsWith(".md")) p += ".md"; return p; } // Published docs live under /docs/ (llms.txt links them there), but doc paths // are relative to that directory. export function docPathFromPathname(pathname) { const path = String(pathname || "") .replace(/^\/+/, "") .replace(/^docs(\/|$)/, ""); return normalizeDocPath(path); }