vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.26k stars 2.14k forks source link

[Feature Proposal] Expand only active sidebar group #4211

Open davestewart opened 2 months ago

davestewart commented 2 months ago

Is your feature request related to a problem? Please describe.

I've added an app level enhancement to my docs site which ensures only the active sidebar group is open when navigating through the site:

The iles framework has the same functionality.

It's pretty nice when you have long sections that would cause the menu to get overly-long and start scrolling.

Describe the solution you'd like

If you click a sidebar group header, or navigate to a page, the active sidebar group would open, and the others would close.

If you click a sidebar group toggle, the group would open / close, without affecting other groups.

The developer would opt-in to this functionality in themeConfig.sidebar.

Describe alternatives you've considered

I've used enhanceApp(), a router handler, and some custom code to achieve this on my own site.

Additional context

Happy to look at PRing this.

It seems that the sidebar composable is the place to start digging around.

Validations