mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
feat: 點擊文字特效增加隨機配置 feat: 可配置是否添加css前綴 fix: 修復子目錄下,配置justifiedGallery CDN(相對鏈接)後,連接會無法訪問的bugs fix: 修復 pangu 配置post 後,仍在全站生效的bugs improvement: 夜間模式下,廣告降低亮度 improvement: 手機端toc邊距微調 improvement: html格式優化 improvement: 搜索優化 improvement: 刪除不必要的語言文件
53 lines
1.5 KiB
Plaintext
53 lines
1.5 KiB
Plaintext
script.
|
|
function addGitalkSource () {
|
|
const ele = document.createElement('link')
|
|
ele.rel = 'stylesheet'
|
|
ele.href= '!{url_for(theme.CDN.gitalk_css)}'
|
|
document.getElementsByTagName('head')[0].appendChild(ele)
|
|
}
|
|
|
|
function loadGitalk () {
|
|
function initGitalk () {
|
|
var gitalk = new Gitalk({
|
|
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)}',
|
|
language: '!{theme.gitalk.language}',
|
|
perPage: !{theme.gitalk.perPage},
|
|
distractionFreeMode: !{theme.gitalk.distractionFreeMode},
|
|
pagerDirection: '!{theme.gitalk.pagerDirection}',
|
|
createIssueManually: !{theme.gitalk.createIssueManually},
|
|
updateCountCallback: commentCount
|
|
})
|
|
gitalk.render('gitalk-container')
|
|
}
|
|
|
|
if (typeof Gitalk === 'function') initGitalk()
|
|
else {
|
|
addGitalkSource()
|
|
getScript('!{url_for(theme.CDN.gitalk)}').then(initGitalk)
|
|
}
|
|
}
|
|
|
|
function commentCount(n){
|
|
let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
|
|
if (isCommentCount) {
|
|
isCommentCount.innerHTML= 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()
|
|
}
|
|
}
|
|
|
|
|
|
|