💄 Add comment counter in home & page.

This commit is contained in:
凡梦星尘
2022-10-30 11:43:18 +08:00
parent d609eecb23
commit e1c088c355
11 changed files with 91 additions and 46 deletions

View File

@@ -5,6 +5,7 @@ NexT.plugins.comments.waline = function() {
|| !NexT.utils.checkDOMExist(element)) return;
const {
comment,
emoji,
imguploader,
pageview,
@@ -39,6 +40,7 @@ NexT.plugins.comments.waline = function() {
locale,
el : element,
pageview : pageview,
comment : comment,
emoji : emoji,
imageUploader : imguploader,
wordLimit : wordlimit,

35
assets/js/third-party/others/counter.js vendored Normal file
View File

@@ -0,0 +1,35 @@
/* Page's view & comment counter plugin */
NexT.plugins.others.counter = function() {
let busz_postview = false;
let pageview_js = undefined;
let comment_js = undefined;
const busz = NexT.CONFIG.busuanzi;
if (busz != undefined && busz.pageview) {
busz_postview = true;
}
// Here can append others pageview & comment plugin
const waline = NexT.CONFIG.waline;
if (waline != undefined){
if(!busz_postview && waline.cfg.pageview) {
pageview_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline.js[0]);
NexT.utils.getScript(pageview_js, function(){
Waline.pageviewCount({
serverURL: waline.cfg.serverurl
});
});
}
if (waline.cfg.comment) {
comment_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline.js[1]);
NexT.utils.getScript(comment_js, function(){
Waline.commentCount({
serverURL: waline.cfg.serverurl
});
});
}
}
}

View File

@@ -1,21 +0,0 @@
/* Waline pageview plugin */
NexT.plugins.others.pageview = function() {
const busz = NexT.CONFIG.busuanzi;
if (busz != undefined && busz.pageview) return;
let pageview_js = undefined;
// Here can append others pageview plugin
const waline = NexT.CONFIG.waline;
if (waline != undefined && waline.cfg.pageview) {
pageview_js = NexT.utils.getCDNResource(NexT.CONFIG.page.pageview.js);
}
if (pageview_js == undefined) return;
NexT.utils.getScript(pageview_js, function(){
Waline.pageviewCount({
serverURL: waline.cfg.serverurl
});
});
}