From 73c63d5c882bdb05194164e74fc2b2f69380ab99 Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 28 Jan 2021 17:44:01 +0800 Subject: [PATCH] refactor: modify the use and configuration of the comment feature --- _config.yml | 6 +++--- layout/_partial/comment/comment.ejs | 18 ++++++++++++------ layout/_partial/comment/gitalk.ejs | 2 +- layout/_partial/comment/twikoo.ejs | 2 +- layout/_partial/comment/valine.ejs | 2 +- layout/_partial/post-tools.ejs | 6 +----- layout/article-content.ejs | 6 +----- .../css/layout/_partial/comment/comment.styl | 15 ++++++++------- 8 files changed, 28 insertions(+), 29 deletions(-) diff --git a/_config.yml b/_config.yml index cccb4f9..8e9b6de 100644 --- a/_config.yml +++ b/_config.yml @@ -167,10 +167,12 @@ local_search: # Comment plugin # --------------------------------------------------------------------------------------- comment: + enable: false + use: valine # values: valine | gitalk | twikoo + # Valine # See: https://github.com/xCss/Valine valine: - enable: false appid: # your leancloud application appid appkey: # your leancloud application appkey placeholder: # your placeholder @@ -178,7 +180,6 @@ comment: # Gitalk # See: https://github.com/gitalk/gitalk gitalk: - enable: false github_id: # GitHub repo owner repository: # Repository name to store issues client_id: # GitHub Application Client ID @@ -187,7 +188,6 @@ comment: # Twikoo # See: https://github.com/imaegoo/twikoo twikoo: - enable: false env_id: # Tencent Cloud environment id region: # environment region. If select Guangzhou, fill in "ap-guangzhou". diff --git a/layout/_partial/comment/comment.ejs b/layout/_partial/comment/comment.ejs index 8a08cc2..3991a7c 100644 --- a/layout/_partial/comment/comment.ejs +++ b/layout/_partial/comment/comment.ejs @@ -3,11 +3,17 @@
 <%- __('comments') %>
- <% if (theme.comment.valine.enable === true) { %> - <%- partial('valine') %> - <% } else if (theme.comment.gitalk.enable === true) { %> - <%- partial('gitalk') %> - <% } else if (theme.comment.twikoo.enable === true) { %> - <%- partial('twikoo') %> + <% if (theme.comment.enable === true && theme.comment.hasOwnProperty(theme.comment.use)) { %> + + <% if (theme.comment.use === 'valine') { %> + <%- partial('valine') %> + + <% } else if (theme.comment.use === 'gitalk') { %> + <%- partial('gitalk') %> + + <% } else if (theme.comment.use === 'twikoo') { %> + <%- partial('twikoo') %> + + <% } %> <% } %> diff --git a/layout/_partial/comment/gitalk.ejs b/layout/_partial/comment/gitalk.ejs index 607f5d6..2c5b73f 100644 --- a/layout/_partial/comment/gitalk.ejs +++ b/layout/_partial/comment/gitalk.ejs @@ -1,5 +1,5 @@ <% if( - theme.comment.gitalk.enable + theme.comment.use === 'gitalk' && theme.comment.gitalk.client_id && theme.comment.gitalk.client_secret && theme.comment.gitalk.github_id diff --git a/layout/_partial/comment/twikoo.ejs b/layout/_partial/comment/twikoo.ejs index b874949..4f1882d 100644 --- a/layout/_partial/comment/twikoo.ejs +++ b/layout/_partial/comment/twikoo.ejs @@ -1,4 +1,4 @@ -<% if(theme.comment.twikoo.enable === true && theme.comment.twikoo.env_id) { %> +<% if(theme.comment.use === 'twikoo' && theme.comment.twikoo.env_id) { %>