mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
feat: 設置了隨系統而切換淺色和深色模式後,評論和 mermaind 也會跟隨切換顏色 feat: artalk 最新評論,從 artalk 配置讀取頭像 CDN 和默認頭像 fix: 修復代碼塊在未展開時,點擊複製按鈕,無法複製的 bug improvement: 代碼和性能優化 improvement: artalk 獲取評論數,由 LoadCountWidget 改為 loadCountWidget
42 lines
1.1 KiB
Plaintext
42 lines
1.1 KiB
Plaintext
script.
|
|
function loadGitalk () {
|
|
function initGitalk () {
|
|
var gitalk = new Gitalk(Object.assign({
|
|
clientID: '!{theme.gitalk.client_id}',
|
|
clientSecret: '!{theme.gitalk.client_secret}',
|
|
repo: '!{theme.gitalk.repo}',
|
|
owner: '!{theme.gitalk.owner}',
|
|
admin: ['!{theme.gitalk.admin}'],
|
|
id: '!{md5(page.path)}',
|
|
updateCountCallback: commentCount
|
|
},!{JSON.stringify(theme.gitalk.option)}))
|
|
|
|
gitalk.render('gitalk-container')
|
|
}
|
|
|
|
if (typeof Gitalk === 'function') initGitalk()
|
|
else {
|
|
getCSS('!{url_for(theme.asset.gitalk_css)}')
|
|
getScript('!{url_for(theme.asset.gitalk)}').then(initGitalk)
|
|
}
|
|
}
|
|
|
|
function commentCount(n){
|
|
let 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 {
|
|
function loadOtherComment () {
|
|
loadGitalk()
|
|
}
|
|
}
|
|
|
|
|
|
|