vitepress
vitepress copied to clipboard
Multiple Nav bars
Is your feature request related to a problem? Please describe.
Functionality to have a secondary nav bar
Describe the solution you'd like
Ability to have a secondary nav bar
Describe alternatives you've considered
No response
Additional context
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Read the Contributing Guidelines.
- [X] Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.
What's the use case?
Instead of a sidebar, it would be nice to have a secondary nav bar. Or have both. It's a feature request. It's ok to ignore this request.
Ah, you want sidebar items to be on navbar? Any particular UI that you have in mind for this? I guess this can be done at your end using the provided navigation slots.
Bootstrap has an example multiple navbars eg https://getbootstrap.com/docs/5.2/examples/offcanvas-navbar/
I just tried to find a solution for this. It seems like siteData is read-only, so it is simply not possible to change the navigation based on the route.
export default {
...DefaultTheme,
setup() {},
enhanceApp(ctx) {
DefaultTheme.enhanceApp(ctx)
ctx.router.onAfterRouteChanged = (to) => {
ctx.siteData.value.themeConfig.nav = {
text: 'Ecosystem',
activeMatch: '^/ecosystem/',
link: '/guide/what-is-vitepress'
}
}
}
}

@brc-dd Is there a specific reason that this is readonly? Is there maybe an easy workarround for this?
I think there are some real world usecases for "dynamic" navigation bars.
I think this should be done in custom theme. We do have nested sidebar for nesting the menu.
Although this secondary navbar is totally valid UI design, I don't think we should keep adding many different navigations to a single theme.