Skip to content

Commit 9159604

Browse files
CITguyyyx990803
authored andcommitted
docs(multiple sidebars): clarify documentation (#190)
1 parent efffb2a commit 9159604

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

docs/default-theme-config/README.md

+28-12
Original file line numberDiff line numberDiff line change
@@ -146,45 +146,61 @@ Sidebar groups are collapsable by default. You can force a group to be always op
146146

147147
### Multiple Sidebars
148148

149-
If you wish to display different sidebars for different group of pages, first organize your pages into directories:
149+
If you wish to display different sidebars for different sections of content, first organize your pages into directories for each desired section:
150150

151151
```
152152
.
153153
├─ README.md
154-
├─ foo
154+
├─ contact.md
155+
├─ about.md
156+
├─ foo/
155157
│  ├─ README.md
156158
│ ├─ one.md
157159
│ └─ two.md
158-
└─ bar
160+
└─ bar/
159161
├─ README.md
160162
├─ three.md
161163
└─ four.md
162164
```
163165

164-
Then, with the following sidebar config:
166+
Then, update your configuration to define your sidebar for each section.
165167

166168
``` js
167169
// .vuepress/config.js
168170
module.exports = {
169171
themeConfig: {
170172
sidebar: {
171-
// sidebar for pages under /foo/
172173
'/foo/': [
173-
'',
174-
'one',
175-
'two'
174+
'', /* /foo/ */
175+
'one', /* /foo/one.html */
176+
'two' /* /foo/two.html */
176177
],
177-
// sidebar for pages under /bar/
178+
178179
'/bar/': [
179-
'',
180-
'three',
181-
'four'
180+
'', /* /bar/ */
181+
'three', /* /bar/three.html */
182+
'four' /* /bar/four.html */
183+
],
184+
185+
// fallback
186+
'/': [
187+
'', /* / */
188+
'contact', /* /contact.html */
189+
'about' /* /about.html */
182190
]
183191
}
184192
}
185193
}
186194
```
187195

196+
::: warning
197+
Make sure to define the fallback configuration last.
198+
199+
VuePress checks each sidebar config from top to bottom. If the fallback configuration was first, VuePress would incorrectly match `/foo/` or `/bar/four.html` because they both start with `/`.
200+
:::
201+
202+
203+
188204
### Auto Sidebar for Single Pages
189205

190206
If you wish to automatically generate a sidebar that contains only the header links for the current page, you can use `YAML front matter` on that page:

0 commit comments

Comments
 (0)