Open shanyuhai123 opened 3 years ago
在使用 v2 的过程中,由于 sidebar 需要手动配置,所以在写文档时会带来一个问题: 有些内容还是草稿,不添加到 sidebar 中就无法看到,而提交后 sidebar 又会导致不该显示的目录,手动修改虽行,但过于繁琐,后续看看能不能提个 PR 解决吧。
在使用 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 中产生它了。
在使用过程中,可以设置侧边栏最大深度为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级标题,该如何设置呢?
在使用过程中,可以设置侧边栏最大深度为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.x 及 vuepress2.x 的默认主题都不支持更多的层级。
VuePress v2
自动导入 sidebar