Skip to content

Commit cc98f56

Browse files
mixj93QingWei-Li
authored andcommitted
fix: {docsify-ignore-all} and {docsify-ignore} bug (#299)
* fix {docsify-ignore-all} not work bug * fix {docsify-ignore} bug
1 parent 752f68e commit cc98f56

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

docs/more-pages.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ This header won't appear in the sidebar table of contents.
8383
To ignore all headers on a specific page, you can use `{docsify-ignore-all}` on the first header of the page.
8484

8585
```markdown
86-
# Getting Started
86+
# Getting Started {docsify-ignore-all}
8787

88-
## Header {docsify-ignore-all}
88+
## Header
8989
This header won't appear in the sidebar table of contents.
9090
```
9191

src/core/render/compiler.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,12 @@ export class Compiler {
191191
const currentPath = this.router.getCurrentPath()
192192
const { cacheTree, toc } = this
193193

194-
toc[0] && toc[0].ignoreAllSubs && (this.toc = [])
194+
toc[0] && toc[0].ignoreAllSubs && toc.splice(0)
195195
toc[0] && toc[0].level === 1 && toc.shift()
196-
toc.forEach((node, i) => {
197-
node.ignoreSubHeading && toc.splice(i, 1)
198-
})
196+
197+
for (let i = 0; i < toc.length; i++) {
198+
toc[i].ignoreSubHeading && toc.splice(i, 1) && i--
199+
}
199200

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

0 commit comments

Comments
 (0)