Skip to content

Commit

Permalink
Merge pull request #897 from kkfive/patch-1
Browse files Browse the repository at this point in the history
perf: 优化twikoo评论,无评论数容器时不调用API获取
  • Loading branch information
jerryc127 authored May 15, 2022
2 parents 9479f8a + cf38250 commit b1e40b3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions layout/includes/third-party/comments/twikoo.pug
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ script.
}

const getCount = () => {
const countELement = document.getElementById('twikoo-count')
if(!countELement) return
twikoo.getCommentsCount({
envId: '!{envId}',
region: '!{region}',
urls: [window.location.pathname],
includeReply: false
}).then(function (res) {
document.getElementById('twikoo-count').innerText = res[0].count
countELement.innerText = res[0].count
}).catch(function (err) {
console.error(err);
});
Expand All @@ -48,4 +50,4 @@ script.
loadTwikoo()
}
}
})()
})()

0 comments on commit b1e40b3

Please sign in to comment.