Skip to content

fix: highlight active toolkit in sidebar#895

Merged
teallarson merged 2 commits intomainfrom
teallarson/find-toolkit-sidebar-gen
Mar 31, 2026
Merged

fix: highlight active toolkit in sidebar#895
teallarson merged 2 commits intomainfrom
teallarson/find-toolkit-sidebar-gen

Conversation

@teallarson
Copy link
Copy Markdown
Contributor

@teallarson teallarson commented Mar 31, 2026

This nitty little thing was bugging me: toolkit pages weren't highlighted in the sidebar when active!

BEFORE:
Screenshot 2026-03-31 at 12 38 02 PM

AFTER:
Screenshot 2026-03-31 at 12 38 57 PM

Summary

  • Nextra's sidebar active-state detection only checks item.route, never item.href
  • Toolkit entries in the generated _meta.tsx files must keep href (Nextra throws a validation error for keys with no matching page on disk), but this means item.route is never set and the active highlight never fires
  • Post-processes the page map in app/layout.tsx after getPageMap() to copy href → route for any item that has href but no route, so Nextra's native detection works without touching the generated files

Test plan

  • Navigate to a toolkit page (e.g. /en/resources/integrations/social/slack) — "Slack" entry is highlighted in the sidebar
  • Navigate to another toolkit (e.g. /en/resources/integrations/social/reddit) — "Reddit" is highlighted, others are not
  • Non-toolkit sidebar items (guides, references, etc.) still highlight correctly
  • pnpm test passes

🤖 Generated with Claude Code


Note

Low Risk
Low risk: small, localized post-processing of the Nextra pageMap to improve sidebar active-state highlighting, with minimal impact outside navigation rendering.

Overview
Fixes missing active-state highlighting for toolkit sidebar entries by post-processing Nextra’s getPageMap() output.

app/layout.tsx now recursively copies href to route for page map items that don’t have a route, enabling Nextra’s built-in active detection for toolkit links without changing generated sidebar metadata.

Written by Cursor Bugbot for commit 1b6ed5e. This will update automatically on new commits. Configure here.

Nextra's sidebar active-state detection only checks `item.route`, never
`item.href`. Toolkit entries in the generated `_meta.tsx` files must use
`href` (Nextra throws a validation error for keys with no matching page
on disk), but that means `item.route` is never set and the sidebar never
highlights the current toolkit.

Post-process the page map after `getPageMap()` to copy `href` → `route`
for any item that has `href` but no `route`, so Nextra's native active
detection works without changing the generated files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Mar 31, 2026 4:45pm

Request Review

@teallarson teallarson marked this pull request as ready for review March 31, 2026 16:37
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

An item with both `href` (no `route`) and `children` would get its
`route` set but its `children` would not be recursed into, silently
skipping any nested items that also need patching. Apply the two
operations independently so both always happen.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@sdserranog sdserranog left a comment

Choose a reason for hiding this comment

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

:shipit:

@teallarson teallarson merged commit 298b4b8 into main Mar 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants