vitepress icon indicating copy to clipboard operation
vitepress copied to clipboard

Multiple Nav bars

Open soongsta opened this issue 3 years ago • 4 comments

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

soongsta avatar Jul 18 '22 03:07 soongsta

What's the use case?

brc-dd avatar Jul 18 '22 04:07 brc-dd

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.

soongsta avatar Jul 18 '22 05:07 soongsta

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.

brc-dd avatar Jul 18 '22 05:07 brc-dd

Bootstrap has an example multiple navbars eg https://getbootstrap.com/docs/5.2/examples/offcanvas-navbar/

soongsta avatar Jul 18 '22 05:07 soongsta

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'
            }
        }
    }
}

image

@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.

MarkusKeck avatar Mar 03 '23 01:03 MarkusKeck

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.

kiaking avatar Mar 03 '23 02:03 kiaking