mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
feat: aside widget 增加排序(只對page頁和sticky內的有效) feat: aside 增加自定義 widget improvement: readmode 優化 improvement: html結構優化
52 lines
1.4 KiB
Plaintext
52 lines
1.4 KiB
Plaintext
- let option = theme.twikoo.option ? JSON.stringify(theme.twikoo.option) : false
|
|
|
|
script.
|
|
(()=>{
|
|
const $countDom = document.getElementById('twikoo-count')
|
|
const init = () => {
|
|
let initData = {
|
|
envId: '!{theme.twikoo.envId}',
|
|
el: '#twikoo-wrap'
|
|
}
|
|
|
|
if (!{Boolean(option)}) {
|
|
const otherData = !{option}
|
|
initData = Object.assign(initData, otherData)
|
|
}
|
|
|
|
twikoo.init(initData)
|
|
}
|
|
|
|
const getCount = () => {
|
|
twikoo.getCommentsCount({
|
|
envId: '!{theme.twikoo.envId}',
|
|
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()
|
|
}
|
|
}
|
|
})() |