From fd4a42c3b549f1e3dbf97184d120c0cdedfd8aee Mon Sep 17 00:00:00 2001 From: Alexandru Cambose Date: Sat, 16 Feb 2019 22:27:11 +0200 Subject: [PATCH] Added filtering in sidebar for ignoreSubHeading --- src/core/render/compiler.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 91b954c..e2147fc 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -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, '') this.cacheTree[currentPath] = tree } @@ -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