From 2d3291d493d6d568af9367c08a1036c2a59229c9 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Tue, 3 Nov 2026 19:35:45 +0000 Subject: [PATCH] docs site: generate landing pages for documented directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit infrastructure.md links to incidents/ the way Gitea renders directories. A static site has no directory listing, so the build now generates a small landing page (with each document's own title) for any documented directory that lacks an index. Build artifact only — no document is touched. --- publishing/build.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/publishing/build.sh b/publishing/build.sh index 0e49dfa..d577b66 100755 --- a/publishing/build.sh +++ b/publishing/build.sh @@ -44,6 +44,29 @@ tar cf - \ # A file that must sit at the site root (crawler rules), not under publishing/. cp publishing/robots.txt "$SITE_SRC/robots.txt" +# The documents sometimes link to a directory (`incidents/`) the way Gitea +# renders it. A static site has no directory listing, so generate a small +# index page for any documented subdirectory that lacks one. This is a build +# artifact — the documents themselves are never touched. +(cd "$SITE_SRC" && find . -mindepth 1 -type d ! -path './publishing*' | while read -r dir; do + if compgen -G "$dir"/*.md >/dev/null && [ ! -f "$dir/index.md" ]; then + dir_name="$(basename "$dir")" + title="$(echo "$dir_name" | sed 's/-/ /g' | sed 's/^./\u&/')" + { + echo "# $title" + echo + echo "Landing page for this directory, generated by the publishing layer — the" + echo "documents themselves live untouched in the repository." + echo + for f in "$dir"/*.md; do + [ "$(basename "$f")" = "index.md" ] && continue + heading="$(grep -m1 '^# ' "$f" | sed 's/^# //' || true)" + echo "- [${heading:-$(basename "$f" .md)}]($(basename "$f"))" + done + } > "$dir/index.md" + fi +done) + # 2. Build. if [ ! -x "$VENV/bin/mkdocs" ]; then echo "Creating build venv at $VENV"