Skip to content

feat(plugin-docs-cli): Extract TOC headings at build time#2744

Merged
sunker merged 1 commit into
mainfrom
docs-cli/manifest-headings-2
Jun 25, 2026
Merged

feat(plugin-docs-cli): Extract TOC headings at build time#2744
sunker merged 1 commit into
mainfrom
docs-cli/manifest-headings-2

Conversation

@sunker

@sunker sunker commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

The Next.js website renders a "Table of contents" for every plugin docs page, listing the h2 and h3 headings in the page. Today those headings are extracted on every page render by re-parsing the full markdown body - a cost paid on the hot path for every page view on grafana.com.

This PR moves heading extraction to build time. The build command in @grafana/plugin-docs-cli now extracts h2/h3 headings from each page and writes them into the generated manifest.json under a new optional headings field on Page. Consumers can then build the TOC straight from the manifest with zero markdown parsing per request.

Extraction reuses parseMarkdown() from @grafana/plugin-docs-parser, so manifest heading IDs match the IDs the same pipeline produces at render time - anchors line up by construction.

Screenshot 2026-05-22 at 10 22 27

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@sunker sunker marked this pull request as ready for review June 25, 2026 08:23
@sunker sunker requested a review from a team as a code owner June 25, 2026 08:23
@sunker sunker requested review from academo, mckn and s4kh June 25, 2026 08:23
@github-project-automation github-project-automation Bot moved this from 📬 Triage to 🔬 In review in Grafana Catalog Team Jun 25, 2026
@sunker sunker merged commit 0a05680 into main Jun 25, 2026
31 checks passed
@sunker sunker deleted the docs-cli/manifest-headings-2 branch June 25, 2026 08:43
@github-project-automation github-project-automation Bot moved this from 🔬 In review to 🚀 Shipped in Grafana Catalog Team Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚀 Shipped

Development

Successfully merging this pull request may close these issues.

2 participants