vitepress-plugin-sidebar

1.0.1 • Public • Published

Generator sidebar for Vitepress based on file and directory structure.

NPM version NPM downloads NPM License

Install

npm install -D vitepress-plugin-sidebar

API

sideBar

sideBar(docDir = './docs', options?: Options)
  • docDir: string Directory to get configuration for, default is docs
  • 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

Package Sidebar

Install

npm i vitepress-plugin-sidebar

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

23.1 kB

Total Files

16

Last publish

Collaborators

  • webkong