vitepress-plugin-sidebar
v1.0.1
Published
A vitepress plugin, according to the structure of the files and folders to automatically generate the sidebar.
Downloads
19
Maintainers
Readme
Generator sidebar for Vitepress based on file and directory structure.
Install
npm install -D vitepress-plugin-sidebar
API
sideBar
sideBar(docDir = './docs', options?: Options)
- docDir:
string
Directory to get configuration for, default isdocs
- options:
Options
Option to create configuration
Options:
interface Options {
ignoreDirectory?: Array<string>; // Directoty path to ignore.
ignoreMDFiles?: Array<string>; // File path to ignore.
// If `true`, group is collapsible and collapsed by default
// If `false`, group is collapsible but expanded by default
collapsed?: boolean;
// If not specified, group is not collapsible.
collapsible?: boolean;
// Default is true. Set false, will not remove number prefix, this options is for sort.
// "01.xxx" -> "xxx"
pure?: boolean;
}
Usage
import { sideBar } from "vitepress-plugin-sidebar";
module.exports = {
// ...
themeConfig: {
// ...
sidebar: sideBar(),
},
};
Ignore Some path
You can pass options to keep some path out of the sidebar.
import { sideBar } from "vitepress-plugin-sidebar";
module.exports = {
// ...
themeConfig: {
// ...
sidebar: sideBar("docs", {
ignoreMDFiles: ["index"],
ignoreDirectory: ["node_modules"],
}),
},
};
Open collapsed
module.exports = {
// ...
themeConfig: {
// ...
sidebar: sideBar("docs", {
ignoreMDFiles: ["index"],
ignoreDirectory: ["node_modules"],
collapsed: false,
collapsible: true,
}),
},
};
The configuration for the sidebar in Vitepress
License
MIT
Copyright (c) 2022-present, webkong