vuepress-theme-reco 主题左侧侧边栏设置
KayKing 9/26/2021 vuepress
# 右侧边栏设置
在使用 vuepress-theme-reco 主题时,默认是使用二级标题来作为右侧的侧边栏展示的
# 全局开启右侧边栏
方法
在 config.js 的 themeConfig 中添加
subSidebar: 'auto'
# 针对某篇文章开启或关闭右侧边栏
在当前文章顶部加入:
---
subSidebar: 'auto'
---
说明
false : 关闭当前页面的右侧边栏; 'auto' : 开启当前页面右侧边栏
# 左侧边栏设置
在 vuepress-theme-reco 中明确提示 sidebar 也是可用的,而 sidebar 就是来设置 左侧侧边栏的
在 vuepress 中 sidebar 的格式也是有好几种的,要想在 vuepress-theme-reco 中使用 左侧侧边栏,博主只推荐下面这种
sidebar = {
'/vuepress-demo/': [
{
title: '许嵩',
children: ['1', '2'],
},
{
title: '徐良',
children: ['3', '4'],
},
],
...其他分类
}
警告
请不要妄图使用在某篇文章中使用 sidebar:false 来取消左侧的侧边栏,这是不可取的,它会把你的右侧侧边栏隐藏掉
目录结构:
├── .vuepress
| └── config.js
|── vuepress-demo
| |── 1.md
| |── 2.md
| |── 3.md
| └── 4.md
|
│── package.json
│
└── yarn.lock