1.0.1 • Published 2 years ago
vitepress-plugin-sidebar v1.0.1
Generator sidebar for Vitepress based on file and directory structure.
Install
npm install -D vitepress-plugin-sidebarAPI
sideBar
sideBar(docDir = './docs', options?: Options)- docDir:
stringDirectory to get configuration for, default isdocs - options:
OptionsOption 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