Add social cards, asset self-hosting and page dates to the docs - #71
Merged
Conversation
Three Material plugins, all built into the theme or a single dependency:
social renders a preview card per page, so a link to the docs unfurls with
the page title and the project logo instead of a bare URL. It needs the
imaging extra (cairosvg, pillow), which also makes mkdocs-material a
declared dependency rather than something reached through mkdocs-jupyter.
privacy downloads the Google Fonts the theme loads and serves them from
this site, removing the third-party request every visitor made for them.
Several things are deliberately left external:
- Google Analytics only works when loaded from Google, so vendoring it
would break the tag and change nothing about the tracking. The consent
banner stays for that reason.
- The README badges are rendered on request. A local copy would freeze
the download counts, coverage and build status at build time.
- The theme bundle names an unpkg URL so it can lazy-load Mermaid.
No page here defines a diagram, and the file is 3.4 MB, which mike
would keep for every version it has ever deployed.
- A Font Awesome kit is a loader whose config points at
ka-f.fontawesome.com, so a local copy still reaches Font Awesome.
git-revision-date-localized shows when a page last changed, which lets a
reader judge whether what they are reading is current. Both docs workflows
already check out with fetch-depth: 0, so the history it needs is there.
Cards and downloaded assets are written to .cache, now restored in CI. A
cold build fetches around thirty font files, and mkdocs runs with --strict,
so one failed download would otherwise fail the build.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds three Material for MkDocs plugins. Two are built into the theme; the third is one dependency.
social
Renders a preview card per page, so a link to the docs unfurls with the page title and the project logo instead of a bare URL. 26 cards are generated.
It needs Material's
imagingextra (cairosvg, pillow). Declaringmkdocs-material[imaging]also fixes something incidental: the theme was previously only reached transitively throughmkdocs-jupyter, even though it is a direct requirement of this site.Card URLs are absolute and built from
site_url, which mike rewrites to include the version prefix during a versioned deploy, so they resolve under/dev/and/0.3.0/alike.privacy
Downloads the Google Fonts the theme loads (
Open Sans,Ubuntu Mono) and serves them from this site, removing the third-party request every visitor currently makes for them. Verified in the built output: zero remaining requests tofonts.googleapis.comorfonts.gstatic.com.Four things are deliberately left external:
unpkg.com/mermaid@11kit.fontawesome.comka-f.fontawesome.com, so a local copy still reaches Font Awesome and only adds a way for the kit to break.Excluding Mermaid and the kit takes the vendored assets from 4.7 MB to 1.3 MB per deployed version.
git-revision-date-localized
Shows when a page last changed, so a reader can judge whether what they are reading is current. Both docs workflows already check out with
fetch-depth: 0, so the history it needs is available. Undateable pages fall back to the build date rather than failing the strict build.CI
Cards and downloaded assets are written to
.cache, now restored in bothdocs.ymlanddeploy-gh-pages.yml. A cold build fetches around thirty font files and mkdocs runs with--strict, so without the cache a single failed download would fail the build.Verification
mkdocs build --strictpasses locally. In the output: 26 social cards,og:imagepointing at the right card, fonts served fromassets/external/, the gtag script still external, and the "Last update" fact rendering on each page.llms.txtand the 26 per-page.mdexports from #69/#70 are unaffected.The one thing not verified locally is that
cairosvgimports on the runner — it needslibcairofrom the system. It is present on ubuntu-latest images, and the docs job on this PR proves it either way before anything merges.🤖 Generated with Claude Code