mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-10 05:48:18 +10:00
fix: Cache TOC for later usage in the case of cached file html (#649)
This commit is contained in:
+27
-13
@@ -85,24 +85,38 @@ export class Compiler {
|
||||
}
|
||||
|
||||
this._marked = compile
|
||||
this.compile = cached(text => {
|
||||
let html = ''
|
||||
this.compile = text => {
|
||||
let isCached = true
|
||||
const result = cached(_ => {
|
||||
isCached = false
|
||||
let html = ''
|
||||
|
||||
if (!text) {
|
||||
return text
|
||||
}
|
||||
if (!text) {
|
||||
return text
|
||||
}
|
||||
|
||||
if (isPrimitive(text)) {
|
||||
html = compile(text)
|
||||
if (isPrimitive(text)) {
|
||||
html = compile(text)
|
||||
} else {
|
||||
html = compile.parser(text)
|
||||
}
|
||||
|
||||
html = config.noEmoji ? html : emojify(html)
|
||||
slugify.clear()
|
||||
|
||||
return html
|
||||
})(text)
|
||||
|
||||
const curFileName = this.router.parse().file
|
||||
|
||||
if (isCached) {
|
||||
this.toc = this.cacheTOC[curFileName]
|
||||
} else {
|
||||
html = compile.parser(text)
|
||||
this.cacheTOC[curFileName] = [...this.toc]
|
||||
}
|
||||
|
||||
html = config.noEmoji ? html : emojify(html)
|
||||
slugify.clear()
|
||||
|
||||
return html
|
||||
})
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
compileEmbed(href, title) {
|
||||
|
||||
Reference in New Issue
Block a user