hexo-theme-butterfly/layout/includes/third-party/card-post-count/twikoo.pug
Jerry 28d1744b9b feat: artalk 支持點擊打開大圖
feat: 設置了隨系統而切換淺色和深色模式後,評論和 mermaind 也會跟隨切換顏色
feat: artalk 最新評論,從 artalk 配置讀取頭像 CDN 和默認頭像
fix: 修復代碼塊在未展開時,點擊複製按鈕,無法複製的 bug
improvement: 代碼和性能優化
improvement: artalk 獲取評論數,由 LoadCountWidget 改為 loadCountWidget
2023-05-09 00:36:00 +08:00

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.textContent = 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)
})()