diff --git a/README.md b/README.md index 27cf738..352ef8a 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,7 @@ graph LR [`docs/00-executive-overview.md`](docs/00-executive-overview.md). ## Using the static site -Open [`docs/site/index.html`](docs/site/index.html) to browse a minimal HTML version of the content with navigation and search. -Open [`site/index.html`](site/index.html) to browse a minimal HTML version of the content with navigation and search. +Open [`docs/index.html`](docs/index.html) to browse a minimal HTML version of the content with navigation and search. ## Repo structure The repository includes: diff --git a/docs/assets/app.js b/docs/assets/app.js index ec5b772..7257f88 100644 --- a/docs/assets/app.js +++ b/docs/assets/app.js @@ -1,20 +1,40 @@ -const pages = [ - { title: "Overview", href: "pages/overview.html" }, - { title: "Service Definition", href: "pages/service-definition.html" }, - { title: "Operating Model", href: "pages/operating-model.html" }, - { title: "Architecture", href: "pages/architecture.html" }, - { title: "KPIs", href: "pages/kpis.html" }, - { title: "Roadmap", href: "pages/roadmap.html" }, - { title: "Runbooks", href: "pages/runbooks.html" }, - { title: "Templates", href: "pages/templates.html" }, - { title: "Hybrid", href: "pages/hybrid.html" } +const pageDefinitions = [ + { title: "Overview", path: "pages/overview.html" }, + { title: "Service Definition", path: "pages/service-definition.html" }, + { title: "Operating Model", path: "pages/operating-model.html" }, + { title: "Architecture", path: "pages/architecture.html" }, + { title: "KPIs", path: "pages/kpis.html" }, + { title: "Roadmap", path: "pages/roadmap.html" }, + { title: "Runbooks", path: "pages/runbooks.html" }, + { title: "Templates", path: "pages/templates.html" }, + { title: "Hybrid", path: "pages/hybrid.html" } ]; +function getBasePath() { + let path = window.location.pathname; + if (path.endsWith("/")) { + path = path.slice(0, -1); + } + if (path.endsWith("/index.html")) { + path = path.slice(0, -"/index.html".length); + } + if (path.includes("/pages/")) { + path = path.split("/pages/")[0]; + } + return path || ""; +} + +function resolveHref(targetPath) { + const basePath = getBasePath(); + const trimmedBase = basePath.replace(/\/$/, ""); + return `${trimmedBase}/${targetPath}`; +} + function buildNav() { const nav = document.getElementById("nav-links"); - pages.forEach((page) => { + pageDefinitions.forEach((page) => { const link = document.createElement("a"); - link.href = page.href; + link.href = resolveHref(page.path); link.textContent = page.title; nav.appendChild(link); }); @@ -25,14 +45,14 @@ function setupSearch() { if (!input) return; input.addEventListener("input", (event) => { const query = event.target.value.toLowerCase(); - const results = pages.filter((page) => + const results = pageDefinitions.filter((page) => page.title.toLowerCase().includes(query) ); const nav = document.getElementById("nav-links"); nav.innerHTML = ""; results.forEach((page) => { const link = document.createElement("a"); - link.href = page.href; + link.href = resolveHref(page.path); link.textContent = page.title; nav.appendChild(link); });