mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 13:07:06 +08:00
fix: 修復點擊toc後,滾動完toc的highlight在點擊的上一個元素 fix: 修復打賞按鈕Hover的bug close #473 improvement: 友情鏈接界面增加title顯示(top_img設為false時) improvement: 優化toc顯示,當向上滾動時,導航欄不會遮擋 toc close #472 improvement: 升級facebook comment sdk版本
37 lines
1018 B
Plaintext
37 lines
1018 B
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('!{theme.CDN.twikoo}').then(runTwikoo)
|
|
}
|
|
}
|
|
|
|
window.pjax ? getCount() : window.addEventListener('load', getCount)
|
|
|
|
})() |