mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
fix: 修復首頁文章 valine 評論數只顯示第一篇的 bug fix: 修復子目錄下,第三方插件本地資源無法加載的 bug closed #908 fix: 評論系統開啟時 busuanzi 的 page_pv 不顯示的 bug closed #902 fix: 修復 pjax 下,使用 mermaid 跳轉會重新加載的 bug
37 lines
1.0 KiB
Plaintext
37 lines
1.0 KiB
Plaintext
script.
|
|
(() => {
|
|
const getCommentUrl = () => {
|
|
const eleGroup = document.querySelectorAll('#recent-posts .article-title')
|
|
let urlArray = []
|
|
eleGroup.forEach(i=>{
|
|
urlArray.push(i.getAttribute('href'))
|
|
})
|
|
return urlArray
|
|
}
|
|
|
|
const getCount = () => {
|
|
const runTwikoo = () => {
|
|
twikoo.getCommentsCount({
|
|
envId: '!{theme.twikoo.envId}',
|
|
region: '!{theme.twikoo.region}',
|
|
urls: getCommentUrl(),
|
|
includeReply: false
|
|
}).then(function (res) {
|
|
document.querySelectorAll('#recent-posts .twikoo-count').forEach((item,index) => {
|
|
item.innerText = res[index].count
|
|
})
|
|
}).catch(function (err) {
|
|
console.log(err)
|
|
})
|
|
}
|
|
|
|
if (typeof twikoo === 'object') {
|
|
runTwikoo()
|
|
} else {
|
|
getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo)
|
|
}
|
|
}
|
|
|
|
window.pjax ? getCount() : window.addEventListener('load', getCount)
|
|
|
|
})() |