Skip to content

Add social cards, asset self-hosting and page dates to the docs - #71

Merged
xhan97 merged 1 commit into
mainfrom
docs/material-plugins
Aug 16, 2026
Merged

Add social cards, asset self-hosting and page dates to the docs#71
xhan97 merged 1 commit into
mainfrom
docs/material-plugins

Conversation

@xhan97

@xhan97 xhan97 commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

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 imaging extra (cairosvg, pillow). Declaring mkdocs-material[imaging] also fixes something incidental: the theme was previously only reached transitively through mkdocs-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 to fonts.googleapis.com or fonts.gstatic.com.

Four things are deliberately left external:

Asset Why
Google Analytics Only works when loaded from Google. Vendoring it breaks the tag and changes nothing about the tracking, so the consent banner stays.
README badges (shields.io, pepy, codecov, repostatus, the Actions badge) Rendered on request by their providers. A local copy would freeze download counts, coverage and build status at build time.
unpkg.com/mermaid@11 The theme bundle names this 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.
kit.fontawesome.com A kit is a loader, not the icons. Its config points at ka-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 both docs.yml and deploy-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 --strict passes locally. In the output: 26 social cards, og:image pointing at the right card, fonts served from assets/external/, the gtag script still external, and the "Last update" fact rendering on each page. llms.txt and the 26 per-page .md exports from #69/#70 are unaffected.

The one thing not verified locally is that cairosvg imports on the runner — it needs libcairo from 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

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>
@xhan97
xhan97 merged commit 6a3ec97 into main Aug 16, 2026
17 checks passed
@xhan97
xhan97 deleted the docs/material-plugins branch August 16, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant