From a05e3f76612d3859680ddddd2c5ebe08abd48f7e Mon Sep 17 00:00:00 2001 From: Wesley Ray Date: Wed, 15 Jul 2026 15:34:20 -0400 Subject: [PATCH] Footer quotes + right-hand table of contents - two static quotes above the name line in every footer - Toc component renders h1-h3 from Astro's render() headings as a sticky right column on >=88rem screens (hidden below); scroll-position highlighting via a small passive listener; shown only when a page has 2+ headings, so listings and short notes stay clean Co-Authored-By: Claude Opus 4.8 --- src/components/Toc.astro | 47 ++++++++++++++++++++++ src/layouts/Base.astro | 84 ++++++++++++++++++++++++++++++++++++++- src/pages/[...slug].astro | 9 ++++- src/pages/index.astro | 9 ++++- 4 files changed, 144 insertions(+), 5 deletions(-) create mode 100644 src/components/Toc.astro diff --git a/src/components/Toc.astro b/src/components/Toc.astro new file mode 100644 index 0000000..1438c19 --- /dev/null +++ b/src/components/Toc.astro @@ -0,0 +1,47 @@ +--- +interface Props { + headings: { depth: number; slug: string; text: string }[]; +} +const { headings } = Astro.props; +const shown = headings.filter((h) => h.depth <= 3); +const min = Math.min(...shown.map((h) => h.depth)); +--- + + + + diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 7328451..f8d56cd 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -3,14 +3,17 @@ import 'katex/dist/katex.min.css'; import { getCollection } from 'astro:content'; import { buildNavTree } from '../lib/nav.mjs'; import NavTree from '../components/NavTree.astro'; +import Toc from '../components/Toc.astro'; interface Props { title: string; description?: string; + headings?: { depth: number; slug: string; text: string }[]; } -const { title, description } = Astro.props; +const { title, description, headings = [] } = Astro.props; const isHome = Astro.url.pathname === '/'; const navTree = buildNavTree(await getCollection('garden')); +const showToc = headings.filter((h) => h.depth <= 3).length >= 2; --- @@ -35,6 +38,13 @@ const navTree = buildNavTree(await getCollection('garden'));