From 2cba3b10cde7a6ddb286a2726ebd492928322505 Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 14:27:56 +0800 Subject: [PATCH 01/35] Add multi-comments --- _config.yml | 4 +++ layout/_partials/comments.swig | 31 +++++++++++++++++++-- scripts/filters/comment/default-config.js | 13 +++++++++ scripts/filters/comment/warn.js | 19 ------------- source/css/_common/components/comments.styl | 27 ++++++++++++++++++ 5 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 scripts/filters/comment/default-config.js delete mode 100644 scripts/filters/comment/warn.js diff --git a/_config.yml b/_config.yml index 6626ab14bd..7cd07bd03d 100644 --- a/_config.yml +++ b/_config.yml @@ -604,6 +604,10 @@ reading_progress: # Comments and Widgets # See: https://theme-next.org/docs/third-party-services/comments-and-widgets # --------------------------------------------------------------- +# Comments system setting +comments: + # If you have mutli-comment-system, active this comment when page loaded. + active: # Disqus disqus: diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index 3250cf4451..8766d94349 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -2,8 +2,33 @@ {%- if theme.injects.comment.length == 1 %} {%- set inject_item = theme.injects.comment[0] %} {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} + {%- else %} +
+ {%- for inject_item in theme.injects.comment %} + + {%- endfor %} +
+ {%- for inject_item in theme.injects.comment %} +
+ {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} +
+ {%- endfor %} + {%- endif %} -{# {%- for inject_item in theme.injects.comment %} - {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} -{%- endfor %} #} {%- endif %} diff --git a/scripts/filters/comment/default-config.js b/scripts/filters/comment/default-config.js new file mode 100644 index 0000000000..52a1440cdf --- /dev/null +++ b/scripts/filters/comment/default-config.js @@ -0,0 +1,13 @@ +/* global hexo */ + +'use strict'; + +const path = require('path'); + +hexo.extend.filter.register('theme_inject', function(injects) { + injects.comment.raws.forEach(element => { + element.args[0] = Object.assign({ + class: path.basename(element.name, path.extname(element.name)) + }, element.args[0]); + }); +}, 99999); diff --git a/scripts/filters/comment/warn.js b/scripts/filters/comment/warn.js deleted file mode 100644 index f040d90d9b..0000000000 --- a/scripts/filters/comment/warn.js +++ /dev/null @@ -1,19 +0,0 @@ -/* global hexo */ - -'use strict'; - -hexo.extend.filter.register('theme_inject', injects => { - if (injects.comment.raws.length > 1) { - hexo.log.warn('It is currently not supported to launch mutli-comments systems at the same time, so stay tuned for subsequent versions of iteration.'); - hexo.log.warn('Please keep one of the following.'); - injects.comment.raws.forEach(element => { - let commentName = element.name; - // List comment system - hexo.log.warn(' - ' + commentName); - // Close comment system - injects.postMeta.raw(commentName, '', {disableDefaultLayout: true}, {cache: true}); - injects.comment.raw(commentName, '', {}, {cache: true}); - injects.bodyEnd.raw(commentName, '', {}, {cache: true}); - }); - } -}, 999); diff --git a/source/css/_common/components/comments.styl b/source/css/_common/components/comments.styl index 9c8a2a0a54..448c0eb3fc 100644 --- a/source/css/_common/components/comments.styl +++ b/source/css/_common/components/comments.styl @@ -2,3 +2,30 @@ margin: 60px 20px 0; overflow: hidden; } + +.comment-button-group { + margin: 2rem 0 1rem; + display: flex; + justify-content: center; + + .comment-button { + background-color: #fff; + border: 0; + cursor: pointer; + padding: 0.6rem 1.2rem; + margin: 0 0.2rem; + border-radius: 0.5rem; + } + + .comment-button.active { + background-color: #ddd; + } + +} + +.comment-position { + display: none; +} +.comment-position.active { + display: block; +} From 1995b1295cc8aeb3aa9629bd1dbc8eeb37334ca3 Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 15:35:43 +0800 Subject: [PATCH 02/35] Update button style --- layout/_partials/comments.swig | 4 ++-- source/css/_common/components/comments.styl | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index 8766d94349..d240a2dd88 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -5,7 +5,7 @@ {%- else %}
{%- for inject_item in theme.injects.comment %} - + {{inject_item.locals.class}} {%- endfor %}
{%- for inject_item in theme.injects.comment %} @@ -17,7 +17,7 @@ let commentButton = document.querySelectorAll('.comment-button'); commentButton.forEach(item => { console.log(item); - let commentClass = item.classList[1]; + let commentClass = item.classList[2]; console.log(commentClass); item.addEventListener("click", () => { commentButton.forEach(rmActive => rmActive.classList.remove('active')); diff --git a/source/css/_common/components/comments.styl b/source/css/_common/components/comments.styl index 448c0eb3fc..1eaba1fa5e 100644 --- a/source/css/_common/components/comments.styl +++ b/source/css/_common/components/comments.styl @@ -9,16 +9,12 @@ justify-content: center; .comment-button { - background-color: #fff; - border: 0; - cursor: pointer; - padding: 0.6rem 1.2rem; margin: 0 0.2rem; - border-radius: 0.5rem; - } - - .comment-button.active { - background-color: #ddd; + &.active { + background: $btn-default-hover-bg; + border-color: $btn-default-hover-border-color; + color: $btn-default-hover-color; + } } } From 4a6ac1e31e033757c008a4055f202a4e93b4fbe4 Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 15:53:23 +0800 Subject: [PATCH 03/35] moblie --- source/css/_common/components/comments.styl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/css/_common/components/comments.styl b/source/css/_common/components/comments.styl index 1eaba1fa5e..33e38b28fc 100644 --- a/source/css/_common/components/comments.styl +++ b/source/css/_common/components/comments.styl @@ -4,12 +4,13 @@ } .comment-button-group { - margin: 2rem 0 1rem; + margin: 1.2em 0 .6em; display: flex; justify-content: center; + flex-wrap: wrap-reverse; .comment-button { - margin: 0 0.2rem; + margin: 0.1em 0.2em; &.active { background: $btn-default-hover-bg; border-color: $btn-default-hover-border-color; From 741a0f513ede5d8303536ca4d1c4a9b319851a9e Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 16:02:17 +0800 Subject: [PATCH 04/35] Fix facebook comments button style --- layout/_partials/comments.swig | 2 +- scripts/filters/comment/default-config.js | 4 +++- scripts/filters/comment/facebook-comments-plugin.js | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index d240a2dd88..109ec0430f 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -5,7 +5,7 @@ {%- else %}
{%- for inject_item in theme.injects.comment %} - {{inject_item.locals.class}} + {{inject_item.locals.button}} {%- endfor %}
{%- for inject_item in theme.injects.comment %} diff --git a/scripts/filters/comment/default-config.js b/scripts/filters/comment/default-config.js index 52a1440cdf..de14e43512 100644 --- a/scripts/filters/comment/default-config.js +++ b/scripts/filters/comment/default-config.js @@ -6,8 +6,10 @@ const path = require('path'); hexo.extend.filter.register('theme_inject', function(injects) { injects.comment.raws.forEach(element => { + let injectName = path.basename(element.name, path.extname(element.name)); element.args[0] = Object.assign({ - class: path.basename(element.name, path.extname(element.name)) + class: injectName, + button: injectName, }, element.args[0]); }); }, 99999); diff --git a/scripts/filters/comment/facebook-comments-plugin.js b/scripts/filters/comment/facebook-comments-plugin.js index 7f34b8a79c..f3d1184a8e 100644 --- a/scripts/filters/comment/facebook-comments-plugin.js +++ b/scripts/filters/comment/facebook-comments-plugin.js @@ -19,7 +19,9 @@ hexo.extend.filter.register('theme_inject', injects => { data-colorscheme="{{ theme.facebook_comments_plugin.scheme }}"> - `); + `, { + button: ' facebook comments' + }); }, priority.facebook_comments_plugin); From ef9909718978cd0bfaea0ed7bdcff16cc93c0022 Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 16:11:34 +0800 Subject: [PATCH 05/35] Fix QA --- scripts/filters/comment/default-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/filters/comment/default-config.js b/scripts/filters/comment/default-config.js index de14e43512..5d70acf1d0 100644 --- a/scripts/filters/comment/default-config.js +++ b/scripts/filters/comment/default-config.js @@ -9,7 +9,7 @@ hexo.extend.filter.register('theme_inject', function(injects) { let injectName = path.basename(element.name, path.extname(element.name)); element.args[0] = Object.assign({ class: injectName, - button: injectName, + button: injectName }, element.args[0]); }); }, 99999); From 9c9ad516a01ad15b6408661d6df61b4d7d15308a Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 16:18:53 +0800 Subject: [PATCH 06/35] Fix comment length is 0 --- _config.yml | 2 +- layout/_partials/comments.swig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index 7cd07bd03d..cb22d02fab 100644 --- a/_config.yml +++ b/_config.yml @@ -606,7 +606,7 @@ reading_progress: # --------------------------------------------------------------- # Comments system setting comments: - # If you have mutli-comment-system, active this comment when page loaded. + # If you want to enable mutli-comment-system, you can active one comment when page loaded. active: # Disqus diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index 109ec0430f..fa4c0dcb8e 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -2,7 +2,7 @@ {%- if theme.injects.comment.length == 1 %} {%- set inject_item = theme.injects.comment[0] %} {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} - {%- else %} + {%- elif theme.injects.comment.length > 1 %}
{%- for inject_item in theme.injects.comment %} {{inject_item.locals.button}} From 058abd6cfa9f510fb9f4d45a4471fc8aeddb989d Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 16:22:33 +0800 Subject: [PATCH 07/35] Rm log --- layout/_partials/comments.swig | 2 -- 1 file changed, 2 deletions(-) diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index fa4c0dcb8e..7e795bac79 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -16,9 +16,7 @@ {%- endif %} From 381736262cb6986ea632e192defa3cc34839ba02 Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 18:30:57 +0800 Subject: [PATCH 10/35] Add localStorage --- layout/_partials/comments.swig | 8 +++++--- scripts/filters/comment/default-config.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index 783cd6cb03..8163957bf6 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -22,14 +22,16 @@ item.classList.add('active'); document.querySelectorAll('.comment-position').forEach(rmActive => rmActive.classList.remove('active')); document.querySelector(`.comment-position.${commentClass}`).classList.add('active'); + localStorage.comments_active = commentClass; }) }) - {%- if theme.comments.active %} - let activeButton = document.querySelector('.comment-button.{{theme.comments.active}}'); + let activeClass = localStorage.comments_active || '{{theme.comments.active}}'; + if (activeClass) { + let activeButton = document.querySelector(`.comment-button.${activeClass}`); if (activeButton) { activeButton.click(); } - {%- endif %} + } {%- endif %} {%- endif %} diff --git a/scripts/filters/comment/default-config.js b/scripts/filters/comment/default-config.js index 5d70acf1d0..418243db99 100644 --- a/scripts/filters/comment/default-config.js +++ b/scripts/filters/comment/default-config.js @@ -4,7 +4,7 @@ const path = require('path'); -hexo.extend.filter.register('theme_inject', function(injects) { +hexo.extend.filter.register('theme_inject', injects => { injects.comment.raws.forEach(element => { let injectName = path.basename(element.name, path.extname(element.name)); element.args[0] = Object.assign({ From 2110957fcf4524be81ebed0da5d544981ac322f4 Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 18:46:40 +0800 Subject: [PATCH 11/35] Refactor localStorage --- _config.yml | 2 ++ layout/_partials/comments.swig | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index df711aff95..b3dfd9fc9f 100644 --- a/_config.yml +++ b/_config.yml @@ -609,6 +609,8 @@ comments: # If you want to enable mutli-comment-system, you can active one comment when page loaded. # active list: changyan | disqus | disqusjs | facebook-comments-plugin | gitalk | livere | valine | vkontakte-comments active: + # If true, storage user selected comment, and active this when page loaded. + storage: false # Disqus disqus: diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index 8163957bf6..0e228a386b 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -22,10 +22,15 @@ item.classList.add('active'); document.querySelectorAll('.comment-position').forEach(rmActive => rmActive.classList.remove('active')); document.querySelector(`.comment-position.${commentClass}`).classList.add('active'); - localStorage.comments_active = commentClass; + {%- if theme.comments.storage %} + localStorage.setItem('comments_active', commentClass); + {%- endif %} }) }) - let activeClass = localStorage.comments_active || '{{theme.comments.active}}'; + let activeClass = '{{theme.comments.active}}'; + {%- if theme.comments.storage %} + activeClass = localStorage.getItem('comments_active') || activeClass; + {%- endif %} if (activeClass) { let activeButton = document.querySelector(`.comment-button.${activeClass}`); if (activeButton) { From 9fb33354d94f62c2cf53fe75bded56bac8a3ed5b Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Sat, 3 Aug 2019 18:47:08 +0800 Subject: [PATCH 12/35] ... --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index b3dfd9fc9f..1c53c869d7 100644 --- a/_config.yml +++ b/_config.yml @@ -610,7 +610,7 @@ comments: # active list: changyan | disqus | disqusjs | facebook-comments-plugin | gitalk | livere | valine | vkontakte-comments active: # If true, storage user selected comment, and active this when page loaded. - storage: false + storage: true # Disqus disqus: From 7f3b57045a82cfac5d26a6071abf95fb7500e603 Mon Sep 17 00:00:00 2001 From: MrTT Date: Sun, 4 Aug 2019 11:38:15 +0800 Subject: [PATCH 13/35] Update facebook style --- scripts/filters/comment/facebook-comments-plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/filters/comment/facebook-comments-plugin.js b/scripts/filters/comment/facebook-comments-plugin.js index f3d1184a8e..3468ba8b23 100644 --- a/scripts/filters/comment/facebook-comments-plugin.js +++ b/scripts/filters/comment/facebook-comments-plugin.js @@ -20,7 +20,7 @@ hexo.extend.filter.register('theme_inject', injects => {
`, { - button: ' facebook comments' + button: ' facebook' }); }, priority.facebook_comments_plugin); From 49349d1a4de1d74df27fb92aec2d6419fe4e535c Mon Sep 17 00:00:00 2001 From: MrTT Date: Sun, 4 Aug 2019 16:11:45 +0800 Subject: [PATCH 14/35] Add custom button support --- _config.yml | 9 +++++++-- scripts/filters/comment/default-config.js | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index 1c53c869d7..c08e61cce1 100644 --- a/_config.yml +++ b/_config.yml @@ -605,12 +605,17 @@ reading_progress: # See: https://theme-next.org/docs/third-party-services/comments-and-widgets # --------------------------------------------------------------- # Comments system setting +# Types: changyan | disqus | disqusjs | facebook-comments-plugin | gitalk | livere | valine | vkontakte-comments comments: - # If you want to enable mutli-comment-system, you can active one comment when page loaded. - # active list: changyan | disqus | disqusjs | facebook-comments-plugin | gitalk | livere | valine | vkontakte-comments + # If you enable mutli comments, you can active one comment type, it will display as default when page loaded. active: # If true, storage user selected comment, and active this when page loaded. storage: true + # Set button style over the default. Configurate as following. + button: + #disqus: disqus + #[facebook-comments-plugin]: facebook + #gitalk: Load Gitalk # Disqus disqus: diff --git a/scripts/filters/comment/default-config.js b/scripts/filters/comment/default-config.js index 418243db99..7fcf9c7af8 100644 --- a/scripts/filters/comment/default-config.js +++ b/scripts/filters/comment/default-config.js @@ -6,10 +6,17 @@ const path = require('path'); hexo.extend.filter.register('theme_inject', injects => { injects.comment.raws.forEach(element => { + // Set default button content let injectName = path.basename(element.name, path.extname(element.name)); element.args[0] = Object.assign({ class: injectName, button: injectName }, element.args[0]); + // Set custom button content + let locals = element.args[0]; + let customButton = hexo.theme.config.comments.button[locals.class]; + if (customButton) { + locals.button = customButton; + } }); }, 99999); From 6598b872513463ceb14c3d5f3fa35709e522253f Mon Sep 17 00:00:00 2001 From: MrTT Date: Sun, 4 Aug 2019 16:13:12 +0800 Subject: [PATCH 15/35] Fix null --- scripts/filters/comment/default-config.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/filters/comment/default-config.js b/scripts/filters/comment/default-config.js index 7fcf9c7af8..5f7e9be5f1 100644 --- a/scripts/filters/comment/default-config.js +++ b/scripts/filters/comment/default-config.js @@ -14,9 +14,11 @@ hexo.extend.filter.register('theme_inject', injects => { }, element.args[0]); // Set custom button content let locals = element.args[0]; - let customButton = hexo.theme.config.comments.button[locals.class]; - if (customButton) { - locals.button = customButton; + if (hexo.theme.config.comments.button) { + let customButton = hexo.theme.config.comments.button[locals.class]; + if (customButton) { + locals.button = customButton; + } } }); }, 99999); From 96fc0f43449dea2530c986443da58335a0032f5a Mon Sep 17 00:00:00 2001 From: MrTT Date: Sun, 4 Aug 2019 17:30:09 +0800 Subject: [PATCH 16/35] Add pjax --- layout/_partials/comments.swig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index 0e228a386b..5572454cc8 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -13,7 +13,7 @@ {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} {%- endfor %} - {%- endif %} {%- endif %} diff --git a/source/css/_common/components/comments.styl b/source/css/_common/components/comments.styl index 33e38b28fc..88ce523c27 100644 --- a/source/css/_common/components/comments.styl +++ b/source/css/_common/components/comments.styl @@ -4,7 +4,7 @@ } .comment-button-group { - margin: 1.2em 0 .6em; + margin: 1em 0; display: flex; justify-content: center; flex-wrap: wrap-reverse; From 31b2329b806a932a73907d093eb50b67026db1e5 Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Mon, 5 Aug 2019 11:33:05 +0800 Subject: [PATCH 18/35] Add tabs style --- _config.yml | 7 +- layout/_partials/comments.swig | 83 ++++++++++++-------- scripts/filters/comment/default-config.js | 5 +- source/css/_common/components/comments.styl | 12 +++ source/css/_common/components/tags/tabs.styl | 2 +- source/css/_schemes/Gemini/index.styl | 3 + 6 files changed, 74 insertions(+), 38 deletions(-) diff --git a/_config.yml b/_config.yml index 4fa423092f..18b34026cd 100644 --- a/_config.yml +++ b/_config.yml @@ -612,12 +612,15 @@ reading_progress: # Comments system setting # Types: changyan | disqus | disqusjs | facebook-comments-plugin | gitalk | livere | valine | vkontakte-comments comments: + # You can choose `buttons` or `tabs` + style: tabs # If you enable mutli comments, you can active one comment type, it will display as default when page loaded. active: # If true, storage user selected comment, and active this when page loaded. + # Only support style is `buttons`. storage: true - # Set button style over the default. Configurate as following. - button: + # Modify button or tabs style over the default. Configurate as following. + nav: #disqus: disqus #[facebook-comments-plugin]: facebook #gitalk: Load Gitalk diff --git a/layout/_partials/comments.swig b/layout/_partials/comments.swig index f9cc2948fc..6f196f708d 100644 --- a/layout/_partials/comments.swig +++ b/layout/_partials/comments.swig @@ -3,42 +3,59 @@ {%- set inject_item = theme.injects.comment[0] %} {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} {%- elif theme.injects.comment.length > 1 %} -
+ {%- if theme.comments.style == 'buttons' %} +
+ {%- for inject_item in theme.injects.comment %} + {{inject_item.locals.button}} + {%- endfor %} +
{%- for inject_item in theme.injects.comment %} - {{inject_item.locals.button}} +
+ {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} +
{%- endfor %} -
- {%- for inject_item in theme.injects.comment %} -
- {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} -
- {%- endfor %} - - (function() { - let commentButton = document.querySelectorAll('.comment-button'); - commentButton.forEach(item => { - let commentClass = item.classList[2]; - item.addEventListener("click", () => { - commentButton.forEach(rmActive => rmActive.classList.remove('active')); - item.classList.add('active'); - document.querySelectorAll('.comment-position').forEach(rmActive => rmActive.classList.remove('active')); - document.querySelector(`.comment-position.${commentClass}`).classList.add('active'); + + (function() { + let commentButton = document.querySelectorAll('.comment-button'); + commentButton.forEach(item => { + let commentClass = item.classList[2]; + item.addEventListener("click", () => { + commentButton.forEach(rmActive => rmActive.classList.remove('active')); + item.classList.add('active'); + document.querySelectorAll('.comment-position').forEach(rmActive => rmActive.classList.remove('active')); + document.querySelector(`.comment-position.${commentClass}`).classList.add('active'); + {%- if theme.comments.storage %} + localStorage.setItem('comments_active', commentClass); + {%- endif %} + }) + }) + let activeClass = '{{theme.comments.active}}'; {%- if theme.comments.storage %} - localStorage.setItem('comments_active', commentClass); + activeClass = localStorage.getItem('comments_active') || activeClass; {%- endif %} - }) - }) - let activeClass = '{{theme.comments.active}}'; - {%- if theme.comments.storage %} - activeClass = localStorage.getItem('comments_active') || activeClass; - {%- endif %} - if (activeClass) { - let activeButton = document.querySelector(`.comment-button.${activeClass}`); - if (activeButton) { - activeButton.click(); - } - } - })(); - + if (activeClass) { + let activeButton = document.querySelector(`.comment-button.${activeClass}`); + if (activeButton) { + activeButton.click(); + } + } + })(); + + {%- elif theme.comments.style == 'tabs' %} +
+ +
+ {%- for inject_item in theme.injects.comment %} +
+ {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} +
+ {%- endfor %} +
+
+ {%- endif %} {%- endif %} {%- endif %} diff --git a/scripts/filters/comment/default-config.js b/scripts/filters/comment/default-config.js index 5f7e9be5f1..5b5c55ef51 100644 --- a/scripts/filters/comment/default-config.js +++ b/scripts/filters/comment/default-config.js @@ -14,8 +14,9 @@ hexo.extend.filter.register('theme_inject', injects => { }, element.args[0]); // Set custom button content let locals = element.args[0]; - if (hexo.theme.config.comments.button) { - let customButton = hexo.theme.config.comments.button[locals.class]; + let nav = hexo.theme.config.comments.nav; + if (nav) { + let customButton = nav[locals.class]; if (customButton) { locals.button = customButton; } diff --git a/source/css/_common/components/comments.styl b/source/css/_common/components/comments.styl index 88ce523c27..3941160862 100644 --- a/source/css/_common/components/comments.styl +++ b/source/css/_common/components/comments.styl @@ -26,3 +26,15 @@ .comment-position.active { display: block; } + +.tabs-comment { + padding-top: 0; + margin-top: 4em; + background: white; + .comments { + margin-top: 0; + padding-top: 0; + border: 0; + box-shadow: none; + } +} diff --git a/source/css/_common/components/tags/tabs.styl b/source/css/_common/components/tags/tabs.styl index 6bcd90083a..49f794d2ed 100644 --- a/source/css/_common/components/tags/tabs.styl +++ b/source/css/_common/components/tags/tabs.styl @@ -1,4 +1,4 @@ -.post-body .tabs { +.post-body .tabs,.tabs-comment { display: block; margin-bottom: 20px; padding-top: 10px; diff --git a/source/css/_schemes/Gemini/index.styl b/source/css/_schemes/Gemini/index.styl index d3231896fd..7875826268 100644 --- a/source/css/_schemes/Gemini/index.styl +++ b/source/css/_schemes/Gemini/index.styl @@ -61,6 +61,9 @@ $use-seo = hexo-config('seo'); margin-top: $sidebar-offset; padding: $content-desktop-padding; } +.tabs-comment { + margin-top: 1em; +} // Top main padding from header to posts (default 40px). .posts-expand { From e31ac2bede4928d46aca62c1ceb0786e5f56499e Mon Sep 17 00:00:00 2001 From: jiangtj <116749895@qq.com> Date: Mon, 5 Aug 2019 12:38:34 +0800 Subject: [PATCH 19/35] Update post meta --- scripts/filters/comment/changyan.js | 2 +- scripts/filters/comment/common.js | 29 ++++++++++++++----- scripts/filters/comment/disqus.js | 2 +- .../comment/facebook-comments-plugin.js | 2 +- scripts/filters/comment/valine.js | 2 +- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/filters/comment/changyan.js b/scripts/filters/comment/changyan.js index a49a1780c2..1fe9cc7a92 100644 --- a/scripts/filters/comment/changyan.js +++ b/scripts/filters/comment/changyan.js @@ -29,7 +29,7 @@ hexo.extend.filter.register('theme_inject', injects => { injects.postMeta.raw('changyan', ` {% if post.comments %}