Skip to content

Commit

Permalink
Added filtering in sidebar for ignoreSubHeading
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcambose authored and timaschew committed Apr 23, 2019
1 parent d355272 commit 6cc069c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,17 @@ export class Compiler {
* Compile sidebar
*/
sidebar(text, level) {
const {toc} = this
const currentPath = this.router.getCurrentPath()
let html = ''

if (text) {
html = this.compile(text)
} else {
const tree = this.cacheTree[currentPath] || genTree(this.toc, level)
for (let i = 0; i < toc.length; i++) {
toc[i].ignoreSubHeading && toc.splice(i, 1) && i--
}
const tree = this.cacheTree[currentPath] || genTree(toc, level)
html = treeTpl(tree, '<ul>{inner}</ul>')
this.cacheTree[currentPath] = tree
}
Expand All @@ -360,7 +364,6 @@ export class Compiler {
for (let i = 0; i < toc.length; i++) {
toc[i].ignoreSubHeading && toc.splice(i, 1) && i--
}

const tree = cacheTree[currentPath] || genTree(toc, level)

cacheTree[currentPath] = tree
Expand Down

0 comments on commit 6cc069c

Please sign in to comment.