Code Monkey home page Code Monkey logo

vitepress-plugin-auto-sidebar's Introduction

vitepress-plugin-auto-sidebar

Automatically generate VitePress sidebar

English | ๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡็‰ˆไป‹็ป

demo

Features

  • ๐Ÿช„ Automatic sidebar generation
  • โœจ Title of files synchronized with sidebar
  • ๐Ÿš€ Automatic reload when files are deleted or title is modified
  • โœ”๏ธ Customizable configuration options (custom directory names, custom file sorting).

Installation

# pnpm
pnpm i @iminu/vitepress-plugin-auto-sidebar
# yarn
yarn add @iminu/vitepress-plugin-auto-sidebar
# npm
npm install @iminu/vitepress-plugin-auto-sidebar

Usage

// .vitepress/config.ts
import AutoSidebar from "@iminu/vitepress-plugin-auto-sidebar";
export default defineConfig({
  vite: {
    plugins: [
      AutoSidebar({
        /**
         * after resolve, we can change it
         */
        sidebarResolved(value) {
          // do sort
          value["/dir2/"][0].items?.sort((a, b) => a.text - b.text);
          // rename
          value["/dir2/"][0].text = "sorted";
        },
        ignores: ["index.md"],
        // Which files are included
        docs: path.resolve(process.cwd(), "docs/demo"),
        /**
         * .vitepress parent folder
         */
        root: path.resolve(process.cwd(), "docs"),,
      }),
    ],
  },
});

How it work

โ”œโ”€โ”€ .vitepress
โ”œโ”€โ”€ dir1
โ”‚   โ”œโ”€โ”€ dir1-1
โ”‚   โ”‚   โ”œโ”€โ”€ 1.md
โ”‚   โ”‚   โ”œโ”€โ”€ 2.md
โ”‚   โ”‚   โ””โ”€โ”€ dir1-1-1
โ”‚   โ”‚       โ””โ”€โ”€ 1.md
โ”‚   โ””โ”€โ”€ dir1-2
โ”‚       โ””โ”€โ”€ 1.md
โ”œโ”€โ”€ dir2
โ”‚   โ””โ”€โ”€ 2-2
โ”‚       โ”œโ”€โ”€ 2.md
โ”‚       โ””โ”€โ”€ 3.md
โ”œโ”€โ”€ index.md
โ”œโ”€โ”€ node_modules
โ””โ”€โ”€ package.json

TO


{
  "/dir2/": [
    {
      "text": "2-2",
      "collapsed": false,
      "items": [
        {
          "text": "2-2",
          "link": "/dir2/2-2/3.md"
        },
        {
          "text": "222",
          "link": "/dir2/2-2/2.md"
        }
      ]
    }
  ],
  "/dir1/": [
    {
      "text": "dir1-2",
      "collapsed": false,
      "items": [
        {
          "text": "1-2",
          "link": "/dir1/dir1-2/1.md"
        }
      ]
    },
    {
      "text": "dir1-1",
      "collapsed": false,
      "items": [
        {
          "text": "2222",
          "link": "/dir1/dir1-1/2.md"
        },
        {
          "text": "1-1",
          "link": "/dir1/dir1-1/1.md"
        },
        {
          "text": "dir1-1-1",
          "collapsed": false,
          "items": [
            {
              "text": "1-1-1",
              "link": "/dir1/dir1-1/dir1-1-1/1.md"
            }
          ]
        }
      ]
    }
  ]
}

vitepress-plugin-auto-sidebar's People

Contributors

mingyuli97 avatar

Stargazers

ykla avatar

Watchers

 avatar

Forkers

oeyoews

vitepress-plugin-auto-sidebar's Issues

่ƒฝๅฆๅ…ผๅฎนไธ€ไธ‹ gitbook ็š„ `SUMMARY.md` ?

ๅณๅฎŒๅ…จ้€š่ฟ‡ SUMMARY.md ๆฅๅฎšไน‰็›ฎๅฝ•็š„็”Ÿๆˆใ€‚

็คบไพ‹๏ผš

## A

* [ๆบฏๅ›  abduction (Igor Douven)](a/su-yin-abduction-igor-douven.md)
* [ๅฝผๅพ—ยท้˜ฟไผฏๆ‹‰ๅฐ” Abelard \[Abailard\], Peter (Peter King and Andrew Arlig)](a/bi-de-abo-la-er-abelard-abailard-peter-peter-king-and-andrew-arlig.md)
* [\*ๅถ็„ถๅฑžๆ€งโ€”โ€”่งๆœฌ่ดจๅฑžๆ€งไธŽๅถ็„ถๅฑžๆ€ง accidental properties โ€” see essential vs. accidental properties](a/ou-ran-shu-xing-jian-ben-zhi-shu-xing-yu-ou-ran-shu-xing-accidental-properties-see-essential-vs.-acc.md)
* [่กŒๅŠจ action (Juan S. Piรฑeros Glasscock and Sergio Tenenbaum)](a/hang-dong-action-juan-s.-pieros-glasscock-and-sergio-tenenbaum/README.md)
  * [\*ๅ…ฑๅŒโ€”โ€”่ง่กŒไธบไฝ“๏ผšๅ…ฑไบซ่กŒไธบไฝ“ joint โ€” see agency: shared](a/hang-dong-action-juan-s.-pieros-glasscock-and-sergio-tenenbaum/gong-tong-jian-neng-dong-xing-gong-xiang-neng-dong-xing-joint-see-agency-shared.md)
  * [\*้€ป่พ‘ โ€”โ€”่ง้€ป่พ‘ๅญฆ๏ผš่กŒๅŠจ็š„้€ป่พ‘ logic of โ€” see logic: action](a/hang-dong-action-juan-s.-pieros-glasscock-and-sergio-tenenbaum/luo-ji-jian-luo-ji-xue-hang-dong-de-luo-ji-logic-of-see-logic-action.md)
* [ๅŸบไบŽ่กŒๅŠจ็š„็Ÿฅ่ง‰็†่ฎบ action-based theories of perception (Robert Briscoe, Rick Grush, and Alison Springle)](a/ji-yu-hang-dong-de-zhi-jue-li-lun-actionbased-theories-of-perception-robert-briscoe-rick-grush-and-a.md)
* [\*่ถ…่ทไฝœ็”จโ€”โ€”่ง้‡ๅญๅŠ›ๅญฆ๏ผš้‡ๅญๅŠ›ๅญฆไธญ็š„่ถ…่ทไฝœ็”จ action at a distance โ€” see quantum mechanics: action at a distance in](a/chao-ju-zuo-yong-jian-liang-zi-li-xue-liang-zi-li-xue-zhong-de-chao-ju-zuo-yong-action-atadistance-s.md)

้žๅธธๆ„Ÿ่ฐขไฝ ใ€‚

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.