feat(plugin-docs-cli): Extract TOC headings at build time#2744
Merged
Conversation
leventebalogh
approved these changes
Jun 25, 2026
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.
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
buildcommand in@grafana/plugin-docs-clinow extracts h2/h3 headings from each page and writes them into the generatedmanifest.jsonunder a new optionalheadingsfield onPage. 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.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: