vuepress-plugin-auto-sidebar icon indicating copy to clipboard operation
vuepress-plugin-auto-sidebar copied to clipboard

Support VuePress v2 or VitePress

Open shanyuhai123 opened this issue 4 years ago • 4 comments

正在推进中。

VuePress v2

  • [x] 基础支持
  • [x] ~~自动导入 sidebar~~
  • [ ] 独立的 CLI,不再依赖于 VuePress
    • 侧边栏
    • 导航栏

shanyuhai123 avatar Jul 03 '21 11:07 shanyuhai123

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

shanyuhai123 avatar Sep 12 '21 03:09 shanyuhai123

在使用 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 中产生它了。

shanyuhai123 avatar Nov 03 '21 17:11 shanyuhai123

在使用过程中,可以设置侧边栏最大深度为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级标题,该如何设置呢?

meizhaohui avatar Sep 07 '22 14:09 meizhaohui

在使用过程中,可以设置侧边栏最大深度为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 的默认主题都不支持更多的层级。

shanyuhai123 avatar Sep 07 '22 15:09 shanyuhai123