mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
feat: 適配 hexo-blog-encrypt fix: 修復 hexo 新版本下,prismjs 的問題 improvement: 在 pjax 關閉的情況下。減少不必要的全局變量 improvement: 更新依賴版本 improvement: 頁面進入效果優化 improvement: 添加平滑滾動 improvement: 兼容性優化 improvement: 優化 lighthouse 分數 improvement: 優化代碼
45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
- 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 btf.getCSS('!{url_for(theme.asset.gitalk_css)}')
|
|
await btf.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
|
|
}
|
|
})()
|
|
|
|
|
|
|