fix: sidebar collapses to first section folder on single-content-dir sites#162
Open
ravisuhag wants to merge 1 commit into
Open
fix: sidebar collapses to first section folder on single-content-dir sites#162ravisuhag wants to merge 1 commit into
ravisuhag wants to merge 1 commit into
Conversation
…sites entry-server pre-scoped the page tree to the active content dir before embedding it, but DocsLayout applies filterPageTreeByContentDir again during both SSR and client rendering. On sites with a single content entry the second pass matched the first section folder (all its URLs are under the content prefix) and unwrapped it, so the sidebar showed only that folder's children and dropped every other page. Embed the version-filtered tree instead and leave content-dir scoping to DocsLayout, which is the single place that does it for SSR and client alike. Verified against raystack/meteor docs (35-extractor sidebar): before, the sidebar rendered only the 7 Concepts pages; after, all 73 pages render in their sections.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe SSR fetch path now filters the page tree by version, compacts it directly, and leaves content-directory scoping to other code instead of applying it in ChangesSSR documentation tree scoping
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Problem
On any site with a single
content:entry, the sidebar renders only the children of the first section folder — every other page and section disappears.Cause
Double application of
filterPageTreeByContentDir:entry-server.tsxscopes the tree to the active content dir before embedding it in__PAGE_DATA__(unwraps the content-root folder).DocsLayoutappliesfilterPageTreeByContentDiragain — during both SSR and client rendering.The function finds the first folder whose URLs are all under
/<contentDir>. On an already-scoped tree that's the first section folder (e.g. Concepts), so the tree collapses to its children.Fix
Embed the version-filtered tree and let
DocsLayoutremain the single scoping point.compactTreestrips therootmarker anyway, so the client could never detect an already-scoped tree.Verification
Built raystack/meteor docs against the patched source: before, the sidebar showed only the 7 Concepts pages; after, all 73 pages render under Concepts / Guides / Extractors (36) / Processors / Sinks / Reference / Contribute. Checked via browser DOM, both SSR and hydrated.