Skip to content

Commit ccf4c7c

Browse files
committed
fix(compiler): force reset toc when rendering sidebar fixed #181
1 parent 9b15d8d commit ccf4c7c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/core/render/compiler.js

+4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ export class Compiler {
135135
* Compile sub sidebar
136136
*/
137137
subSidebar (level) {
138+
if (!level) {
139+
this.toc = []
140+
return
141+
}
138142
const currentPath = this.router.getCurrentPath()
139143
const { cacheTree, toc } = this
140144

src/core/render/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export function renderMixin (proto) {
8585
const activeEl = getAndActive(this.router, '.sidebar-nav', true, true)
8686
if (loadSidebar && activeEl) {
8787
activeEl.parentNode.innerHTML += this.compiler.subSidebar(subMaxLevel)
88+
} else {
89+
// reset toc
90+
this.compiler.subSidebar()
8891
}
8992
// bind event
9093
this._bindEventOnRendered()

0 commit comments

Comments
 (0)