
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
vitepress-plugin-nested-sidebar-test
Advanced tools
Generate the VitePress sidebar through the folder structure.
Generate Nested sidebar. Support Multiple Sidebar. Support TypeScript
Developed by Logic Spark team
Basic Sidebar
Multiple Sidebar
The plugin is created with Vite + TypeScript. To start using this library, please make sure to install the following external libraries first:
Support Node.js 18.12.0 (LTS) and above
There are a few ways you can install Plugin, namely npm, yarn and pnpm. If you install via npm, here is a single cmd to install this library
npm install vitepress-plugin-nested-sidebar
yarn add vitepress-plugin-nested-sidebar
pnpm add vitepress-plugin-nested-sidebar
You will need to import generateSidebar function and Layout.vue file. Without Layout.vue file, the lib may not work properly.
You will need to import function to generateSidebar menu under themeConfig setting of .vitpress/config.mts file:
import VitepressPluginNestedSidebar from "vitepress-plugin-nested-sidebar";
There is one required option, sidebars. The option supports both native basic and multiple sidebars which are native to Vitepress.
_Note: For more details of both types of sidebars, please check out Sidebar of Vitepress documentation.
| Options | Type | Required | Description |
|---|---|---|---|
sidebars | object|array | Yes | define sidebar menu name and link .md file in order to generate the headers use array for Basic sidebaruse object for Multiple sidebar |
excludeFile | array | Optional | exclude file to not to generate in the sidebar menu |
includeIndexMd | boolean | Optional | generate the sidebar menu item from index.md |
[
{
text: string; /*optional*/ /*sidebar name*/
link: string; /*optional*/ /*link to .md file*/
collapsed: boolean; /*optional*/
}
]
{
['file':string]:{
text: string; /*optional*/
link: string; /*optional*/
collapsed: boolean; /*optional*/
}
}
These 4 functions support the generateSidebar to work as intended:
calculateAndHighlightHeader - Check for scroll position with respect to the nearest header
calculateAndHighlightHeader(
header:{
text,
link,
items,
},
options:{
idName, /*optional /*in case of use another div to scroll*/
adjustOffsetTop /*optional*/
})
checkMultipleSidebar - Check themeConfig sidebar if it is multiple or not
checkMultipleSidebar(sidebar:Object | Array)
resetHeader - Use to reset scroll position to the top
resetHeader();
filterSidebar - Filter the sidebar
filterSidebar(compare:string)
The utility functions need information from theme site and page which is retrieved from useData of the vitepress lib. And because the information can only be used within the .vue file, without the Layout.vue file, the utility functions may not work.
Per Vitepress's Setup Wizard, there are three options
Layout.vue and index.ts filesLayout.vue fileimport VitepressPluginNestedSidebar from "vitepress-plugin-nested-sidebar";
const { utility } = VitepressPluginNestedSidebar;
const {
calculateAndHighlightHeader,
resetHeader,
filterSidebar,
checkMultipleSidebar,
} = utility;
Note: You can also apply this instruction to Option 2 and Option 3. For the full sample in accordance with the live demo, please see our example directory.
Distributed under the MIT License. See LICENSE for more information.
Vitepress is licensed under MIT License. Click here for more information.
FAQs
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.