fix(docs): align prev/next navigation with sidebar order #887
+54
−1
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.
Description
This PR fixes the docs prev/next navigation so it follows the sidebar order defined in
docsConfig, instead of the fumadocs page tree (which is alphabetical).By using the sidebar configuration as the source of truth, this change improves navigation consistency and ensures users move through the docs in the same order they see in the UI.
Changes
Prev/Next source
docsConfig.sidebarNav, matching the sidebar flow(e.g. Getting Started → Templates → Components by section).
config/docs.tsgetFlattenedDocsNav()to flattensidebarNavinto a linear list.getNeighboursFromConfig(currentUrl)to return the previous/next items for a given URL.Doc page logic
app/(docs)/docs/[[...slug]]/page.tsxnow:getNeighboursFromConfig(page.url)first.findNeighbour(source.pageTree, page.url)when the page is not listed in the config(e.g. new or unlisted docs).
URL matching
/docs/installationand/docs/installation/are treated as the same URL.Motivation
Single source of truth
docsConfig.sidebarNav, while prev/next relied on fumadocs’ page tree, causing mismatches.Better UX
(e.g. Components → Special Effects → Animations → …).
Easier maintenance
config/docs.ts; prev/next updates automatically.Breaking Changes
docsConfig.Screenshots
N/A — navigation/UX fix with no visual layout changes.