feat: mobile header and sidebar navigation#2180
Conversation
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
To help visualize how these actions would look in the header versus the sidebar, I’ve added them to both. This is a temporary setup and will be revisited once we make a final decision. |
|
Yep, in my opinion the theme switcher and the language selector should always be visible, like Node.js has it, similar to the last change you made. For the search, I’m not sure how you’re planning to implement it, maybe a modal like in Node.js? Either way, I prefer having them easily accessible, since it reduces the number of clicks a user has to make to use those features. I haven’t reviewed the code for the latest changes yet, I’ll do that tomorrow, but I wanted to share my opinion in advance, since the time difference might affect when I’m able to review again, usually in the afternoon/evening GMT-5. One more note: we’ll need to fix that part, I know it was more of a demo of how you wanted it to look, but there’s a layout shift when switching between dark mode and light mode. |
Ok, so at this point, I think that we all agree to move both the theme switcher and the language selector into the header. Yep, I did notice the layout shift, I’m fixing it now, as we’ve reached a final decision on the placement. Regarding the search: my plan was to stick to the Figma design, assuming this layout was already approved. The current proposal uses a full-screen search modal on mobile and tablet, and a lateral sidebar on desktop. Let me know if this works for you, or if you’d like to revisit the approach. Thanks for the review, I’ll wait for your feedback today. |
|
Okay, I like the code. The only thing I don’t think we should do is reload the page every time a different version is selected. We can also complete the menu in a follow-up PR, since it’s quite a bit of manual work. What would be great to handle right away, though, is making sure the URL doesn’t change when selecting a new version. I’m also trying to figure out what needs to be merged or added, since we haven’t been very good at adding APIs or keeping things up to date, which is something that needs to change . Anyway, I’m tracking it here #2186 . It’s not something for Orama, but it is for the Express team. |
@bjohansebas Thanks for the review! I have some concerns about removing URL changes for version switching:
I would keep the URL versioning but try to implement smooth SPA-like transitions between versions. What do you think? |
|
No, I don’t mean removing the URL. I mean reloading the page when a version is selected, I don’t think we should do that. We can simply load the menu when a specific version is selected, without reloading the page. |
Got it, I misunderstood sorry! You basically want to give users the ability to explore what's available in different versions without reloading pages, right? Example: I'm on If the example is correct and reflects your expectation, I have questions about a few critical edge cases: Active item: Since I'm viewing v5 content but showing v4 menu, there would be no active item. Is this expected? Let me know so I can understand the user scenario you have in mind and implement this correctly. Ty |
yeah!
yes it's expected
I think we should go back to menu 5, or to the version that’s in the URL
Hmm, yes, by reloading the page or switching between URLs of the same version.
revert to v5
I understand there might be some confusion, but if the guides or APIs are the same, it’s acceptable
I’m not sure there’s any page that has implemented it yet |
@bjohansebas Thanks for clarifying! Would you mind if I manage this in a different branch (created from this one)? Just to have the 2 different behaviours comparable. Also, can you please clarify how you expect to handle this case: |
Do you want to handle this in another PR? I don’t have any problem with that, so you can merge this and continue working on the desktop part as well.
Here I think we should show the guides for the latest version and display a note saying that there are no guides for v3. We should also mention that v3 is in end-of-life and include a link to the support page. |
mm yes, maybe better closing this PR. |
bjohansebas
left a comment
There was a problem hiding this comment.
From my side, everything looks good. We can proceed with the next PRs
|
I noticed that Body.astro, BodyMd.astro, BodySm.astro, and BodyXs.astro are nearly identical wrapper components. We could significantly reduce code duplication by consolidating these into a single or component that accepts a size or variant prop (e.g., I've left them as is for now to match the current pattern, but it's worth considering for a future cleanup! |
Makes sense! I've noted this for future interaction. TY |




Preview: https://deploy-preview-2180--expressjscom-preview.netlify.app/
This PR introduces a comprehensive sidebar navigation system for the Express.js documentation with multi-level navigation support, version-aware content filtering, and accessibility features.
Overview
The Sidebar component provides a hierarchical navigation system that supports:
Menu Configuration
Menus are configured using TypeScript files in
astro/src/config/:Menu Structure
Menu Items
Menu items can be either links or submenu triggers:
Organizing Navigation Items
Sections
Related items can be grouped under titled sections:
Nested Submenus (Multi-level Navigation)
Create up to 5 levels of navigation by nesting submenus:
Version-Based Content Filtering
Adding/Omitting Items by Version
Use the
omitFromproperty to hide items from specific versions:Omitting Entire Sections
Hide entire sections from specific versions:
How Version Filtering Works
/en/docs/v5/...)omitFromcontaining the current version are excludedVersion Switcher Integration
The sidebar includes an integrated version switcher that appears when navigating into versioned submenus:
Key features:
/en/docs/v4/pageto/en/docs/v5/pageKeyboard Navigation & Accessibility
Keyboard Controls
Escape: Navigate back one level (or close sidebar if at root)Tab/Shift+Tab: Navigate between focusable elementsARIA Implementation
role="dialog"andaria-modal="true"for sidebararia-expandedon submenu triggersaria-hiddenfor inactive navigation panelsaria-labelfor navigation landmarksActive State Detection
The sidebar automatically detects and highlights the current page:
sidebar-nav-item--activeclass to current page linkTechnical Architecture
Component Structure
Key Logic
collectAllSubmenus(): Recursively collects all nested submenus during buildshouldOmitItem()/shouldOmitSection(): Version-based filteringresolveHref(): Constructs full URLs with language, version, and basePathsubmenuContainsCurrentPath(): Checks if a submenu contains the active pagecalculateInitialActiveLevel(): Determines which navigation level to show on loadConfiguration Files
Create new menu configurations in
astro/src/config/:main-menu.ts- Root level navigationdocs-menu.ts- Documentation submenuapi-reference-menu.ts- API reference submenumiddleware-menu.ts- Middleware submenutypes.ts- TypeScript type definitionsExample: Adding a New Menu Item
Notes
Please note that: