Skip to content

Conversation

@rudy128
Copy link
Contributor

@rudy128 rudy128 commented Dec 25, 2025

📌 Fixes
Fixes #3579

📝 Summary of Changes
Implemented sidebar highlighting and folder expansion for direct route URLs (/docs/direct/*) to match the behavior of canonical category routes.

Changes Made

  • Added DirectRouteHighlighter component to handle client-side route highlighting
  • Extended page-map.ts to export directRouteMap mapping direct routes to canonical routes
  • Updated docs layout.tsx to integrate the highlighter component
  • Added barrel export in components/docs/index.tsx for consistency
  • Implemented automatic parent folder expansion for direct links
  • Applied Nextra's exact active state CSS classes for visual consistency

Checklist
Please ensure the following before submitting your PR:

  • I have reviewed the project's contribution guidelines.
  • I have written unit tests for the changes (if applicable). (N/A - client-side UI component)
  • I have updated the documentation (if applicable). (N/A - internal framework change)
  • I have tested the changes locally and ensured they work as expected.
  • My code follows the project's coding standards.

Screenshots or Logs (if applicable)

Before:
2025-12-25_10-39

  • Visiting /docs/direct/get-started showed no sidebar entry
  • Parent folders remained collapsed

After:
2025-12-25_10-41

  • Visiting /docs/direct/get-started highlights "Get started" in the sidebar
  • "Install & Configure" parent folder automatically expands
  • Visual styling matches native Nextra behavior for /docs/install-configure/get-started

👀 Reviewer Notes

Why This Approach?

I explored several alternatives before settling on client-side DOM manipulation:

  1. ❌ Adding duplicate links to pageMap: Would create duplicate navigation entries in the sidebar, causing UI clutter and confusing users with two identical links.

  2. ❌ Using Next.js route aliases/rewrites: Nextra's sidebar highlighting is deeply tied to the pageMap structure. Route aliases would serve the same content but wouldn't help Nextra recognize which sidebar item to highlight since the route doesn't exist in the pageMap.

  3. ❌ Modifying Nextra's core route matching: Would require forking or monkey-patching Nextra's internal navigation logic, making upgrades difficult and breaking compatibility.

  4. ✅ Client-side highlighting (chosen approach):

    • Non-invasive: Works alongside Nextra without modifying its core
    • Maintainable: Isolated in a single component, easy to update or remove
    • Zero breaking changes: Existing routes continue to work normally
    • User-friendly: Direct links now provide the same UX as canonical links
    • Future-proof: When users navigate away, Nextra's native behavior takes over seamlessly

Technical Details:

  • Maps direct routes (/docs/direct/file) to canonical routes (/docs/category/file)
  • Uses MutationObserver to handle dynamic sidebar rendering
  • Applies exact Nextra CSS classes (x:bg-primary-100, x:font-semibold, etc.) for visual consistency
  • Manipulates collapse containers and ARIA attributes to expand parent folders
  • Multiple timeout attempts ensure reliability with async sidebar loading

💬 Open to Feedback
If this approach doesn't align with the project's architecture or preferences, I'm happy to refactor using any alternative solution the maintainers suggest. Please let me know if you'd prefer:

  • A different technical approach
  • Changes to the implementation
  • Alternative architectural patterns

Implements DirectRouteHighlighter component to highlight sidebar items
and expand parent folders when navigating via /docs/direct/* URLs.
Maps direct routes to canonical routes for consistent navigation UX.
@netlify
Copy link

netlify bot commented Dec 25, 2025

Deploy Preview for kubestellar-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c37d671
🔍 Latest deploy log https://app.netlify.com/projects/kubestellar-docs/deploys/694cc9434f4da70008ea72b6
😎 Deploy Preview https://deploy-preview-448--kubestellar-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

👋 Hello! @rudy128 Welcome to the Kubestellar.

Thank you for submitting your first Pull Request to KubeStellar. We are delighted to have you in our Universe!
Please make sure to check out our Contribution Guide and feel free to join our Slack channel for any questions.

@oksaumya oksaumya added documentation Improvements or additions to documentation frontend typescript and removed frontend typescript labels Dec 26, 2025
@oksaumya
Copy link
Member

@vedansh-5

@oksaumya
Copy link
Member

looks good

@oksaumya oksaumya merged commit dbf26bc into kubestellar:main Dec 29, 2025
6 of 7 checks passed
naman9271 added a commit that referenced this pull request Jan 1, 2026
naman9271 added a commit that referenced this pull request Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation frontend pages typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with page: get started - not in navigaqtion tree

2 participants