mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 14:07:06 +08:00
fix: 修復 background-image 遇到連結有括號時會無法顯示的bug fix: Readmode 標題邊距 fix: 修復twikoo 評論數獲取會因為地域問題報錯的bug
54 lines
1.5 KiB
Plaintext
54 lines
1.5 KiB
Plaintext
- let option = theme.twikoo.option ? JSON.stringify(theme.twikoo.option) : false
|
|
|
|
script.
|
|
(()=>{
|
|
const $countDom = document.getElementById('twikoo-count')
|
|
const init = () => {
|
|
let initData = {
|
|
el: '#twikoo-wrap',
|
|
envId: '!{theme.twikoo.envId}',
|
|
region: '!{theme.twikoo.region}'
|
|
}
|
|
|
|
if (!{Boolean(option)}) {
|
|
const otherData = !{option}
|
|
initData = Object.assign(initData, otherData)
|
|
}
|
|
|
|
twikoo.init(initData)
|
|
}
|
|
|
|
const getCount = () => {
|
|
twikoo.getCommentsCount({
|
|
envId: '!{theme.twikoo.envId}',
|
|
region: '!{theme.twikoo.region}',
|
|
urls: [window.location.pathname],
|
|
includeReply: false
|
|
}).then(function (res) {
|
|
$countDom.innerText = res[0].count
|
|
}).catch(function (err) {
|
|
console.error(err);
|
|
});
|
|
}
|
|
|
|
const loadTwikoo = (bool = false) => {
|
|
if (typeof twikoo === 'object') {
|
|
init()
|
|
bool && $countDom && setTimeout(getCount,0)
|
|
} else {
|
|
getScript('!{theme.CDN.twikoo}').then(()=> {
|
|
init()
|
|
bool && $countDom && setTimeout(getCount,0)
|
|
})
|
|
}
|
|
}
|
|
|
|
if ('!{theme.comments.use[0]}' === 'Twikoo' || !!{theme.comments.lazyload}) {
|
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
|
|
else loadTwikoo(true)
|
|
} else {
|
|
window.loadOtherComment = () => {
|
|
loadTwikoo()
|
|
}
|
|
}
|
|
})() |