Skip to content

Commit 06d632b

Browse files
committed
Added filtering in sidebar for ignoreSubHeading
1 parent 8cd786c commit 06d632b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/render/compiler.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,17 @@ export class Compiler {
329329
* Compile sidebar
330330
*/
331331
sidebar(text, level) {
332+
const {toc} = this
332333
const currentPath = this.router.getCurrentPath()
333334
let html = ''
334335

335336
if (text) {
336337
html = this.compile(text)
337338
} else {
338-
const tree = this.cacheTree[currentPath] || genTree(this.toc, level)
339+
for (let i = 0; i < toc.length; i++) {
340+
toc[i].ignoreSubHeading && toc.splice(i, 1) && i--
341+
}
342+
const tree = this.cacheTree[currentPath] || genTree(toc, level)
339343
html = treeTpl(tree, '<ul>{inner}</ul>')
340344
this.cacheTree[currentPath] = tree
341345
}
@@ -360,7 +364,6 @@ export class Compiler {
360364
for (let i = 0; i < toc.length; i++) {
361365
toc[i].ignoreSubHeading && toc.splice(i, 1) && i--
362366
}
363-
364367
const tree = cacheTree[currentPath] || genTree(toc, level)
365368

366369
cacheTree[currentPath] = tree

0 commit comments

Comments
 (0)