Plugin Docs CLI: Always sort root index.md first in manifest#2636
Open
sunker wants to merge 1 commit into
Open
Plugin Docs CLI: Always sort root index.md first in manifest#2636sunker wants to merge 1 commit into
sunker wants to merge 1 commit into
Conversation
Contributor
dedc051 to
e3cc7dc
Compare
e3cc7dc to
9697550
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates @grafana/plugin-docs-cli’s manifest generation so that a root-level index.md (the landing/overview page) is always sorted first in the generated manifest.json, even when sidebar_position is omitted. This prevents the overview page from being pushed to the bottom of the docs nav when authors rely on default ordering.
Changes:
- Update page sorting to always prioritize root
index.mdahead ofsidebar_positionordering. - Add a regression test fixture and test case covering “no
sidebar_positionon root index”. - Introduce new docs fixtures to validate the corrected ordering behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/plugin-docs-cli/src/scanner.ts | Adjusts sorting comparator to place root index.md first before applying sidebar_position ordering. |
| packages/plugin-docs-cli/src/scanner.test.ts | Adds test ensuring root index.md is the first manifest page when it has no sidebar_position. |
| packages/plugin-docs-cli/src/fixtures/no-position-index-docs/index.md | New fixture root index page without sidebar_position. |
| packages/plugin-docs-cli/src/fixtures/no-position-index-docs/guide.md | New fixture page with sidebar_position to ensure index still sorts first. |
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:
When a plugin is packaged,
@grafana/plugin-docs-cliruns a build step that scans the docs folder and generates amanifest.jsondescribing the page tree. Pages are sorted bysidebar_positionfrontmatter, with files that don't set it falling back toInfinity, sorting them last.The root
index.md(the landing page) has no special sort treatment, so plugin authors who omitsidebar_positionend up with their overview page at the bottom of the nav on grafana.com (as shown in the screenshot below, where the overview is missing from the top of the docs nav). The fix givesindex.mdimplicit first-place priority in the sort, without requiring authors to setsidebar_positionmanually.Which issue(s) this PR fixes:
Special notes for your reviewer:
📦 Published PR as canary version:
Canary Versions✨ Test out this PR locally via:
npm install website@5.6.1-canary.2636.26226198477.0 npm install @grafana/create-plugin@7.6.1-canary.2636.26226198477.0 npm install @grafana/plugin-docs-cli@0.0.11-canary.2636.26226198477.0 npm install @grafana/plugin-meta-extractor@0.12.3-canary.2636.26226198477.0 # or yarn add website@5.6.1-canary.2636.26226198477.0 yarn add @grafana/create-plugin@7.6.1-canary.2636.26226198477.0 yarn add @grafana/plugin-docs-cli@0.0.11-canary.2636.26226198477.0 yarn add @grafana/plugin-meta-extractor@0.12.3-canary.2636.26226198477.0