From c64790f2e72242ed6b4f3a6a54dc5e7ceba54bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Randall=20Havens=20=E2=96=B3=20The=20Empathic=20Tec?= =?UTF-8?q?hnologist=20=E2=9F=81=20Doctor=20Who=2042?= Date: Sat, 8 Nov 2025 23:53:48 -0600 Subject: [PATCH] Update app.js --- public/app.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/public/app.js b/public/app.js index da748e0..a8a84e6 100755 --- a/public/app.js +++ b/public/app.js @@ -33,7 +33,6 @@ async function init() { } } -// TOP NAV: Only real section folders with index.* function populateNav() { els.primaryNav.innerHTML = 'Home'; const navSections = [...new Set( @@ -46,7 +45,6 @@ function populateNav() { }); } -// DROPDOWN: Only sections with NON-index files function populateSections() { els.sectionSelect.innerHTML = ''; indexData.sections.forEach(s => { @@ -167,7 +165,7 @@ function renderSubNav(parent) { async function handleHash() { els.viewer.innerHTML = ""; const rel = location.hash.replace(/^#\//, ""); - const parts = rel.split("/").filter(Boolean); + const parts = rel.split("/").filter(Boolean); // ["about", "Mark"] let parentSection = null; if (parts.length >= 1) { @@ -182,17 +180,20 @@ async function handleHash() { if (!rel) return renderDefault(); + // CASE 1: Deep section with trailing slash → e.g., #about/Mark/ if (rel.endsWith('/')) { - const section = parts[0]; - const indexFile = indexData.flat.find(f => - f.path.startsWith(section + "/") && f.isIndex + const fullPath = parts.join("/"); // "about/Mark" + const expectedIndexPath = fullPath + "/"; // "about/Mark/" + + const indexFile = indexData.flat.find(f => + f.path.startsWith(expectedIndexPath) && f.isIndex ); if (indexFile) { try { if (indexFile.ext === ".md") { const src = await fetch(indexFile.path).then(r => r.ok ? r.text() : ""); - const html = marked.parse(src || `# ${section}\n\nNo content yet.`); + const html = marked.parse(src || `# ${fullPath.split("/").pop()}\n\nNo content yet.`); els.viewer.innerHTML = `
${html}
`; } else { const iframe = document.createElement("iframe"); @@ -209,7 +210,7 @@ async function handleHash() { if (!hasContent) { doc.body.innerHTML = `
-

${section}

+

${fullPath.split("/").pop()}

No content yet.

`; @@ -219,14 +220,17 @@ async function handleHash() { }; } } catch (e) { - els.viewer.innerHTML = `

${section}

No content yet.

`; + els.viewer.innerHTML = `

${fullPath.split("/").pop()}

No content yet.

`; } } else { - els.sectionSelect.value = section; + // Fallback: treat as section list + els.sectionSelect.value = parentSection; renderList(); - loadDefaultForSection(section); + loadDefaultForSection(parentSection); } - } else { + } + // CASE 2: Direct file → e.g., #about/Mark/bio.md + else { const file = indexData.flat.find(f => f.path === rel); if (!file) { els.viewer.innerHTML = "

404

Not found.

";