From cc98f56cdd4ccfce54bb643ebafc10cb26a4f6a3 Mon Sep 17 00:00:00 2001 From: Li Xueli Date: Tue, 31 Oct 2017 21:19:48 +0800 Subject: [PATCH] fix: {docsify-ignore-all} and {docsify-ignore} bug (#299) * fix {docsify-ignore-all} not work bug * fix {docsify-ignore} bug --- docs/more-pages.md | 4 ++-- src/core/render/compiler.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/more-pages.md b/docs/more-pages.md index 9b605b5c..9ced12e2 100644 --- a/docs/more-pages.md +++ b/docs/more-pages.md @@ -83,9 +83,9 @@ This header won't appear in the sidebar table of contents. To ignore all headers on a specific page, you can use `{docsify-ignore-all}` on the first header of the page. ```markdown -# Getting Started +# Getting Started {docsify-ignore-all} -## Header {docsify-ignore-all} +## Header This header won't appear in the sidebar table of contents. ``` diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index b308a479..fc140f19 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -191,11 +191,12 @@ export class Compiler { const currentPath = this.router.getCurrentPath() const { cacheTree, toc } = this - toc[0] && toc[0].ignoreAllSubs && (this.toc = []) + toc[0] && toc[0].ignoreAllSubs && toc.splice(0) toc[0] && toc[0].level === 1 && toc.shift() - toc.forEach((node, i) => { - node.ignoreSubHeading && toc.splice(i, 1) - }) + + for (let i = 0; i < toc.length; i++) { + toc[i].ignoreSubHeading && toc.splice(i, 1) && i-- + } const tree = cacheTree[currentPath] || genTree(toc, level)