Skip to content

Plugin Docs CLI: Always sort root index.md first in manifest#2636

Open
sunker wants to merge 1 commit into
mainfrom
sunker/fix-root-index-sort-order
Open

Plugin Docs CLI: Always sort root index.md first in manifest#2636
sunker wants to merge 1 commit into
mainfrom
sunker/fix-root-index-sort-order

Conversation

@sunker
Copy link
Copy Markdown
Contributor

@sunker sunker commented May 18, 2026

What this PR does / why we need it:

When a plugin is packaged, @grafana/plugin-docs-cli runs a build step that scans the docs folder and generates a manifest.json describing the page tree. Pages are sorted by sidebar_position frontmatter, with files that don't set it falling back to Infinity, sorting them last.

The root index.md (the landing page) has no special sort treatment, so plugin authors who omit sidebar_position end 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 gives index.md implicit first-place priority in the sort, without requiring authors to set sidebar_position manually.

Before After
Screenshot 2026-05-21 at 16 59 56 Screenshot 2026-05-21 at 16 59 12

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

@sunker sunker added patch Increment the patch version when merged release Create a release when this pr is merged labels May 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged and will trigger a new patch release.
NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

@sunker sunker force-pushed the sunker/fix-root-index-sort-order branch from dedc051 to e3cc7dc Compare May 18, 2026 19:41
@tolzhabayev tolzhabayev moved this from 📬 Triage to 🧑‍💻 In development in Grafana Catalog Team May 20, 2026
@sunker sunker force-pushed the sunker/fix-root-index-sort-order branch from e3cc7dc to 9697550 Compare May 21, 2026 12:34
@sunker sunker marked this pull request as ready for review May 21, 2026 14:56
@sunker sunker requested a review from a team as a code owner May 21, 2026 14:56
@sunker sunker requested review from Ukochka, academo, Copilot, mckn and toddtreece and removed request for a team May 21, 2026 14:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md ahead of sidebar_position ordering.
  • Add a regression test fixture and test case covering “no sidebar_position on 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged release Create a release when this pr is merged

Projects

Status: 🧑‍💻 In development

Development

Successfully merging this pull request may close these issues.

3 participants