shanyuhai123 / vuepress-plugin-auto-sidebar

vuepress 自动生成侧边栏的插件。
https://shanyuhai123.github.io/vuepress-plugin-auto-sidebar/
MIT License
136 stars 29 forks source link

Support VuePress v2 or VitePress #44

Open shanyuhai123 opened 3 years ago

shanyuhai123 commented 3 years ago

正在推进中。

VuePress v2

shanyuhai123 commented 2 years ago

在使用 v2 的过程中,由于 sidebar 需要手动配置,所以在写文档时会带来一个问题: 有些内容还是草稿,不添加到 sidebar 中就无法看到,而提交后 sidebar 又会导致不该显示的目录,手动修改虽行,但过于繁琐,后续看看能不能提个 PR 解决吧。

shanyuhai123 commented 2 years ago

在使用 v2 的过程中,由于 sidebar 需要手动配置,所以在写文档时会带来一个问题: 有些内容还是草稿,不添加到 sidebar 中就无法看到,而提交后 sidebar 又会导致不该显示的目录,手动修改虽行,但过于繁琐,后续看看能不能提个 PR 解决吧。

针对这种情况作了另辟蹊径的处理,在 config 中配置:

const sidebarConf = require('./sidebar')

module.exports = {
  plugins: [
    ["vuepress-plugin-auto-sidebar", {
      git: {
        // `add` 表示跟踪执行了 `git add` 的文件,`commit` 表示跟踪执行了 `git commit` 的文件
        // 不填写则跟踪所有状态
        trackStatus: 'add'
      }
    }]
  ],
  themeConfig: {
    sidebar: sidebarConf
  }
}

忽略未跟踪的文件,这样就不会在 sidebar 中产生它了。

meizhaohui commented 1 year ago

在使用过程中,可以设置侧边栏最大深度为2:

 "vuepress-plugin-auto-sidebar" : {
   // 侧边栏深度
   // the max value is 2 which extracts both h2 and h3 headers
   sidebarDepth: 2 
}

由于写文章中,有非常多的h4标题,如: 1.1.1.1, 1.1.1.2 等,如果想在侧边栏显示h4级标题,该如何设置呢?

shanyuhai123 commented 1 year ago

在使用过程中,可以设置侧边栏最大深度为2:

 "vuepress-plugin-auto-sidebar" : {
   // 侧边栏深度
   // the max value is 2 which extracts both h2 and h3 headers
   sidebarDepth: 2 
}

由于写文章中,有非常多的h4标题,如: 1.1.1.1, 1.1.1.2 等,如果想在侧边栏显示h4级标题,该如何设置呢?

这个控制不了,因为 vuepress1.xvuepress2.x 的默认主题都不支持更多的层级。