diff --git a/mkdocs.yml b/mkdocs.yml index fdda977..e04cfd3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -87,6 +87,11 @@ plugins: # Built-in, offline search — the index is a JSON file in the build output. - search +hooks: + # Rewrites directory-style links (e.g. [incidents/](incidents/)) to the + # landing pages the build generates for them. Publishing-layer logic only. + - publishing/hooks.py + markdown_extensions: - admonition - attr_list diff --git a/publishing/build.sh b/publishing/build.sh index d577b66..1c91831 100755 --- a/publishing/build.sh +++ b/publishing/build.sh @@ -34,6 +34,7 @@ tar cf - \ --exclude='.site-build' \ --exclude='.venv-docs' \ --exclude='*.sh' \ + --exclude='*.py' \ --exclude='publishing/webhook-receiver.py' \ --exclude='publishing/webhook-receiver.service' \ --exclude='mkdocs.yml' \ diff --git a/publishing/hooks.py b/publishing/hooks.py new file mode 100644 index 0000000..b453b6f --- /dev/null +++ b/publishing/hooks.py @@ -0,0 +1,38 @@ +"""MkDocs hook: make directory-style links work on a static site. + +The documents sometimes link to a directory the way Gitea renders it, e.g. +infrastructure.md contains [`incidents/`](incidents/). On a static site with +directory URLs, that href resolves relative to the *page* (giving +/infrastructure/incidents/ and a 404). This hook rewrites such links to the +generated landing page for that directory (build.sh creates +