Hexo个人博客
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

- const { client_id, client_secret, repo, owner, admin, option } = theme.gitalk
script.
(() => {
const initGitalk = () => {
const gitalk = new Gitalk(Object.assign({
clientID: '!{client_id}',
clientSecret: '!{client_secret}',
repo: '!{repo}',
owner: '!{owner}',
admin: ['!{admin}'],
id: '!{md5(page.path)}',
updateCountCallback: commentCount
},!{JSON.stringify(option)}))
gitalk.render('gitalk-container')
}
const loadGitalk = async() => {
if (typeof Gitalk === 'function') initGitalk()
else {
await getCSS('!{url_for(theme.asset.gitalk_css)}')
await getScript('!{url_for(theme.asset.gitalk)}')
initGitalk()
}
}
const commentCount = n => {
const isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
if (isCommentCount) {
isCommentCount.textContent= n
}
}
if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
else loadGitalk()
} else {
window.loadOtherComment = loadGitalk
}
})()