Skip to content

Commit

Permalink
fix: can't render toc on first load
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed May 31, 2017
1 parent 91b66a5 commit d9b487e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export class Compiler {

_initRenderer () {
const renderer = new marked.Renderer()
const { linkTarget, router, toc, contentBase } = this
const { linkTarget, router, contentBase } = this
const _self = this
/**
* render anchor tag
* @link https://github.com/chjj/marked#overriding-renderer-methods
Expand All @@ -67,7 +68,7 @@ export class Compiler {
const slug = slugify(text)
const url = router.toURL(router.getCurrentPath(), { id: slug })
nextToc.slug = url
toc.push(nextToc)
_self.toc.push(nextToc)

return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${text}</span></a></h${level}>`
}
Expand Down

0 comments on commit d9b487e

Please sign in to comment.