Skip to content

Commit 11ea1f8

Browse files
committed
fix: re-render gitalk when router changed
1 parent bc4d06b commit 11ea1f8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Diff for: src/plugins/gitalk.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ function install(hook) {
77
const main = dom.getNode('#main')
88
div.style = `width: ${main.clientWidth}px; margin: 0 auto 20px;`
99
dom.appendTo(dom.find('.content'), div)
10-
const script = dom.create('script')
11-
const content = `gitalk.render('gitalk-container')`
12-
script.textContent = content
13-
dom.appendTo(dom.body, script)
10+
})
11+
12+
hook.doneEach(_ => {
13+
const el = document.getElementById('gitalk-container')
14+
while (el.hasChildNodes()) {
15+
el.removeChild(el.firstChild)
16+
}
17+
18+
// eslint-disable-next-line
19+
gitalk.render('gitalk-container')
1420
})
1521
}
1622

0 commit comments

Comments
 (0)