Skip to content

Commit

Permalink
fix(comment): 指定地址的评论计数统计
Browse files Browse the repository at this point in the history
  • Loading branch information
inkss committed Jun 10, 2022
1 parent 6607ccf commit 482601a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
20 changes: 14 additions & 6 deletions layout/_meta/artalkcount.ejs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<% if (theme.comments.service == 'artalk'){ %>
<% if (theme.comments.service == 'artalk' && page.comments !== false) { %>
<div class="new-meta-item comments-count">
<%
var path = post.path || page.path;
if (path.length > 9 && (path.substring(path.length - 10) == 'index.html')) {
path = path.substring(0, path.length - 10);
}
if(!!theme.comments.artalk.path) path = theme.comments.artalk.path
let commentPath;
let path = post.path || page.path;
if (theme.comments.service && theme.comments.service.length > 0) {
let service = theme.comments.service;
if (page.comments == undefined || page.comments != false) {
if (service in page && page[service].path) {
commentPath = page[service].path;
}
}
}
if(!!theme.comments.artalk.path) path = theme.comments.artalk.path
if(commentPath) path = commentPath;
path = path.replaceAll('/index.html', '/').replaceAll('.html', '')
%>
<a href="<%- url_for(path) %>#comments">
<i class="<%- theme.article.body.meta_library.artalkcount.icon %> fa-fw"></i>
Expand Down
13 changes: 11 additions & 2 deletions layout/_meta/counter.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<%
let path = post.path || page.path;
if (path.length > 9 && (path.substring(path.length - 10) == 'index.html')) {
path = path.substring(0, path.length - 10);
let commentPath;
if (theme.comments.service && theme.comments.service.length > 0) {
let service = theme.comments.service;
if (page.comments == undefined || page.comments != false) {
if (service in page && page[service].path) {
commentPath = page[service].path;
}
}
}
if(commentPath) path = commentPath;
path = path.replaceAll('/index.html', '/').replaceAll('.html', '')
%>

<% if (!!page.comments) { %>
Expand Down
17 changes: 17 additions & 0 deletions layout/_meta/walinecount.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
}
if(!!theme.comments.waline.path) path = theme.comments.waline.path
%>
<%
let commentPath;
let path = post.path || page.path;
if (theme.comments.service && theme.comments.service.length > 0) {
let service = theme.comments.service;
if (page.comments == undefined || page.comments != false) {
if (service in page && page[service].path) {
commentPath = page[service].path;
}
}
}
if(!!theme.comments.waline.path) path = theme.comments.waline.path
if(commentPath) path = commentPath;
path = path.replaceAll('/index.html', '/').replaceAll('.html', '')
%>
<a href="<%- url_for(path) %>#comments">
<i class="<%- theme.article.body.meta_library.walinecount.icon %> fa-fw"></i>
<p>
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/comments/artalk/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
path = '<%= theme.comments.artalk.path %>' || decodeURI(window.location.pathname);
}
if(!'<%= config.permalink %>'.includes('/index.html')) {
path = path.replaceAll('/index.html', '/')
path = path.replaceAll('/index.html', '/').replaceAll('.html', '')
}
new Artalk(Object.assign(<%- JSON.stringify(theme.comments.artalk) %>, {
Expand Down

0 comments on commit 482601a

Please sign in to comment.