From 180cbaeb708a27badeadaeae1625012812f77e2d Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Fri, 23 Jul 2021 12:10:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=20beaudar=20=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 16 +++++-- .../plugins/comments/beaudar/layout.ejs | 41 +++++++++++++++++ .../plugins/comments/beaudar/script.ejs | 25 +++++++++++ layout/_partial/plugins/comments/layout.ejs | 7 +-- .../plugins/comments/utterances/layout.ejs | 44 ++++++++++++------- 5 files changed, 107 insertions(+), 26 deletions(-) create mode 100644 layout/_partial/plugins/comments/beaudar/layout.ejs create mode 100644 layout/_partial/plugins/comments/beaudar/script.ejs diff --git a/_config.yml b/_config.yml index ab70835..4a67aa1 100755 --- a/_config.yml +++ b/_config.yml @@ -68,16 +68,24 @@ article: ######## Comments ######## comments: - service: # utterances, valine + service: # beaudar, utterances, valine, twikoo + # beaudar + # https://beaudar.lipk.org/ + beaudar: + repo: xxx/xxx + issue-term: pathname + issue-number: + theme: preferred-color-scheme + input-position: top # top/bottom 评论框位置 + comment-order: desc # desc 排序 + keep-theme: # true/false # utterances # https://utteranc.es/ utterances: repo: xxx/xxx issue-term: pathname issue-number: - theme: - light: github-light - dark: github-dark + theme: preferred-color-scheme valine: js: https://cdn.jsdelivr.net/gh/XuxuGood/simple-blog-cdn@main/js/Valine.min.js appId: # your appId diff --git a/layout/_partial/plugins/comments/beaudar/layout.ejs b/layout/_partial/plugins/comments/beaudar/layout.ejs new file mode 100644 index 0000000..ad4a823 --- /dev/null +++ b/layout/_partial/plugins/comments/beaudar/layout.ejs @@ -0,0 +1,41 @@ +<% +function layoutDiv() { + const cmt = 'beaudar'; + // 合并配置参数 + var config = Object.assign({}, theme.comments[cmt]); + if (page.layout === 'wiki' && page.wiki) { + let proj = theme.wiki.projects[page.wiki]; + if (proj[cmt] !== undefined) { + Object.assign(config, proj[cmt]); + } + } + Object.assign(config, page[cmt]); + // 合并评论数据 + if (config['issue-number'] !== null) { + config['issue-term'] = null; + } else { + if (page.comment_id !== undefined) { + config['issue-term'] = page.comment_id; + } else if (page.layout === 'wiki' && page.wiki) { + let proj = theme.wiki.projects[page.wiki]; + if (proj.comment_id !== undefined) { + config['issue-term'] = proj.comment_id; + } + } + } + // 布局 + var el = ''; + el += '
+ + + +<%- layoutDiv() %> diff --git a/layout/_partial/plugins/comments/beaudar/script.ejs b/layout/_partial/plugins/comments/beaudar/script.ejs new file mode 100644 index 0000000..8b518b8 --- /dev/null +++ b/layout/_partial/plugins/comments/beaudar/script.ejs @@ -0,0 +1,25 @@ + diff --git a/layout/_partial/plugins/comments/layout.ejs b/layout/_partial/plugins/comments/layout.ejs index 4806905..d470bd9 100644 --- a/layout/_partial/plugins/comments/layout.ejs +++ b/layout/_partial/plugins/comments/layout.ejs @@ -8,13 +8,8 @@ if (theme.comments.service && theme.comments.service.length > 0) { // 合并项目评论 if (loadComment && page.layout === 'wiki' && page.wiki) { let proj = theme.wiki.projects[page.wiki]; - if (proj.comment_id !== undefined && page.comment_id === undefined) { - if (theme.comments.service === 'utterances') { - page.comment_id = proj.comment_id; - } - } if (proj.comment_title !== undefined && page.comment_title === undefined) { - if (theme.comments.service === 'utterances') { + if (['utterances', 'beaudar'].includes(theme.comments.service)) { page.comment_title = proj.comment_title; } } diff --git a/layout/_partial/plugins/comments/utterances/layout.ejs b/layout/_partial/plugins/comments/utterances/layout.ejs index cefa5be..03fdf60 100644 --- a/layout/_partial/plugins/comments/utterances/layout.ejs +++ b/layout/_partial/plugins/comments/utterances/layout.ejs @@ -1,22 +1,34 @@ <% function layoutDiv() { + const cmt = 'utterances'; + // 合并配置参数 + var config = Object.assign({}, theme.comments[cmt]); + if (page.layout === 'wiki' && page.wiki) { + let proj = theme.wiki.projects[page.wiki]; + if (proj[cmt] !== undefined) { + Object.assign(config, proj[cmt]); + } + } + Object.assign(config, page[cmt]); + // 合并评论数据 + if (config['issue-number'] !== null) { + config['issue-term'] = null; + } else { + if (page.comment_id !== undefined) { + config['issue-term'] = page.comment_id; + } else if (page.layout === 'wiki' && page.wiki) { + let proj = theme.wiki.projects[page.wiki]; + if (proj.comment_id !== undefined) { + config['issue-term'] = proj.comment_id; + } + } + } + // 布局 var el = ''; - el += '