diff --git a/content/en/history/bibliography/_index.md b/content/en/history/bibliography/_index.md index 3f5110ed..d1c6a953 100644 --- a/content/en/history/bibliography/_index.md +++ b/content/en/history/bibliography/_index.md @@ -3,9 +3,12 @@ title: Bibliography heading: Interlisp Bibliography type: bibliography robots: "noindex, follow" +# Keep this section visible in the sidebar. Hugo merges a section's own +# cascade into its own Params, so cascade.toc_hide alone would hide it. +toc_hide: false cascade: type: bibliography - toc_hide: false + toc_hide: true weight: 5 aliases: - /bibliography/ diff --git a/content/en/history/bibliography/intake/_index.md b/content/en/history/bibliography/intake/_index.md index 97991332..0c0843ec 100644 --- a/content/en/history/bibliography/intake/_index.md +++ b/content/en/history/bibliography/intake/_index.md @@ -2,6 +2,10 @@ title: Interlisp Bibliography Intake Guide weight: 1 type: docs +# Explicitly visible in the sidebar: the parent bibliography section's +# cascade sets toc_hide:true (to keep generated entries out of the nav), +# and Hugo merges cascade into children's Params too. +toc_hide: false --- ## I have something I think belongs in the Interlisp Bibliography! diff --git a/tests/test_hugo_build.py b/tests/test_hugo_build.py index 24596afc..55c22fee 100644 --- a/tests/test_hugo_build.py +++ b/tests/test_hugo_build.py @@ -160,6 +160,75 @@ def test_bibliography_section_present(self): ) +class TestHistorySidebarNavigation: + """The Bibliography section must be reachable from History navigation. + + Regression tests for PR #347: setting only ``cascade.toc_hide`` hid the + Bibliography entry itself from the History sidebar (Hugo merges a + section's own cascade into its own Params). The empty + ``layouts/_partials/section-index.html`` override is intentional and + must keep suppressing the subpage cards. Either deviation must break + the build tests. + """ + + @pytest.fixture(autouse=True) + def history_page(self, production_build): + self.build_result = production_build + path = PROD_PUBLIC / "history" / "index.html" + if not path.exists(): + pytest.skip("history/index.html not found — run a production build first") + self.content = path.read_text(encoding="utf-8", errors="ignore") + + def test_bibliography_in_sidebar_nav(self) -> None: + """The sidebar nav on /history/ must link to /history/bibliography/.""" + nav = re.search( + r']*id="td-section-nav".*?', + self.content, + re.DOTALL, + ) + assert nav, "sidebar nav #td-section-nav not found on history page" + assert "/history/bibliography/" in nav.group(0), ( + "Bibliography entry missing from the History sidebar navigation" + ) + + def test_intake_guide_in_sidebar_nav(self) -> None: + """The Intake Guide must be listed under Bibliography, while the + hundreds of generated entries must stay out of the nav.""" + nav = re.search( + r']*id="td-section-nav".*?', + self.content, + re.DOTALL, + ) + assert nav, "sidebar nav #td-section-nav not found on history page" + nav_html = nav.group(0) + assert "/history/bibliography/intake/" in nav_html, ( + "Intake Guide entry missing from the sidebar navigation" + ) + stray_entries = re.findall( + r'href="/history/bibliography/(?!intake/)[a-z0-9]+/"', nav_html + ) + assert not stray_entries, ( + "Generated bibliography entries leaking into sidebar navigation:\n" + + "\n".join(stray_entries[:10]) + ) + + def test_no_subpage_cards(self) -> None: + """The History page must not render section-index subpage cards; + subpage navigation lives in the sidebar. The empty + ``layouts/_partials/section-index.html`` override suppresses them.""" + assert '
' not in self.content, ( + "section-index subpage list should be suppressed on the History page" + ) + + def test_no_sidebar_truncation_warning(self) -> None: + """Hugo must not truncate sidebar entries — a flood of unhidden + bibliography entries (e.g. from a stale Zotero cache without + ``toc_hide``) would trigger this Docsy warning.""" + assert "sidebar entries have been truncated" not in ( + self.build_result.stderr or "" + ), "Sidebar entries were truncated — bibliography entries may be leaking into navigation" + + class TestInternalLinks: """All internal href links in the built HTML must resolve to existing pages."""