Skip to content

Add rehype-inject-figure plugin#582

Open
DavertMik wants to merge 2 commits into
docsfrom
rehype-inject-figure
Open

Add rehype-inject-figure plugin#582
DavertMik wants to merge 2 commits into
docsfrom
rehype-inject-figure

Conversation

@DavertMik
Copy link
Copy Markdown
Contributor

Summary

  • New src/lib/rehype-inject-figure.mjs plugin that injects captioned <figure> elements into docs pages at a specified heading — driven by a declarative array in astro.config.mjs, no markdown edits required.
  • Supports before / after placement relative to the heading and an optional replace mode to swap a specific element (e.g. a table) with the figure.
  • First injection: the running-tests-options.svg diagram on the Running Tests Manually page.
  • Adds hast-util-from-html dependency and supporting styles in custom.css to handle the injected figure's wrapper and zoomable child.
  • Adds a Cloudflare status CI workflow.

Test plan

  • npm install succeeds with the new hast-util-from-html dependency.
  • npm run dev — confirm the figure renders above How to Launch from the Tests Page on /project/runs/running-tests-manually.
  • Editing public/running-tests-options.svg triggers a full reload in dev.
  • npm run build completes; no link-validator regressions.
  • Cloudflare status workflow appears in the Actions tab on the next push.

🤖 Generated with Claude Code

New rehype plugin (src/lib/rehype-inject-figure.mjs) that inserts captioned
figures into docs pages at a specified heading without editing the markdown.
Each figure is configured in a single declarative array in astro.config.mjs
(slug, afterHeading, before, replace, src, alt, width/height, caption).
Includes a Vite dev-server hook to full-reload on /public/*.svg changes so
diagrams hot-update.

First injection: the running-tests-options diagram on the Running Tests
Manually page. Adds hast-util-from-html dependency, supporting styles in
custom.css, and a Cloudflare status CI workflow.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 27, 2026

Deploying docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 66575cd
Status: ✅  Deploy successful!
Preview URL: https://165843f1.docs-c7r.pages.dev
Branch Preview URL: https://rehype-inject-figure.docs-c7r.pages.dev

View logs

@github-actions
Copy link
Copy Markdown

⏱️ Cloudflare Build Status Unknown

Could not determine Cloudflare deployment status within 15 minutes.

Please check the Cloudflare Dashboard manually.

Drop the example figureInjections entry and the corresponding SVG asset;
the plugin ships with an empty injections array by default.
@github-actions
Copy link
Copy Markdown

⏱️ Cloudflare Build Status Unknown

Could not determine Cloudflare deployment status within 15 minutes.

Please check the Cloudflare Dashboard manually.

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