mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
feat: 添加Remark42评论支持
This commit is contained in:
11
_config.yml
11
_config.yml
@@ -259,7 +259,7 @@ addtoany:
|
|||||||
|
|
||||||
comments:
|
comments:
|
||||||
# Up to two comments system, the first will be shown as default
|
# Up to two comments system, the first will be shown as default
|
||||||
# Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus
|
# Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42
|
||||||
use: # Valine,Disqus
|
use: # Valine,Disqus
|
||||||
text: true # Display the comment name next to the button
|
text: true # Display the comment name next to the button
|
||||||
# lazyload: The comment system will be load when comment element enters the browser's viewport.
|
# lazyload: The comment system will be load when comment element enters the browser's viewport.
|
||||||
@@ -354,6 +354,15 @@ giscus:
|
|||||||
dark: dark
|
dark: dark
|
||||||
option:
|
option:
|
||||||
|
|
||||||
|
# Remark42
|
||||||
|
# https://remark42.com/docs/getting-started/installation/
|
||||||
|
remark42:
|
||||||
|
host: # required
|
||||||
|
siteId: remark # Your Site ID
|
||||||
|
language: en # https://remark42.com/docs/configuration/frontend/#locales
|
||||||
|
showEmailSubscription: true
|
||||||
|
simpleView: false
|
||||||
|
|
||||||
# Chat Services
|
# Chat Services
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,11 @@ hr
|
|||||||
when 'Waline'
|
when 'Waline'
|
||||||
#waline-wrap
|
#waline-wrap
|
||||||
when 'Giscus'
|
when 'Giscus'
|
||||||
#giscus-wrap
|
#giscus-wrap
|
||||||
when 'Facebook Comments'
|
when 'Facebook Comments'
|
||||||
.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light'
|
.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light'
|
||||||
data-numposts= theme.facebook_comments.pageSize || 10
|
data-numposts= theme.facebook_comments.pageSize || 10
|
||||||
data-order-by= theme.facebook_comments.order_by || 'social'
|
data-order-by= theme.facebook_comments.order_by || 'social'
|
||||||
data-width="100%")
|
data-width="100%")
|
||||||
|
when 'Remark42'
|
||||||
|
#remark42
|
||||||
|
|||||||
2
layout/includes/third-party/comments/js.pug
vendored
2
layout/includes/third-party/comments/js.pug
vendored
@@ -20,3 +20,5 @@ each name in theme.comments.use
|
|||||||
!=partial('includes/third-party/comments/giscus', {}, {cache: true})
|
!=partial('includes/third-party/comments/giscus', {}, {cache: true})
|
||||||
when 'Facebook Comments'
|
when 'Facebook Comments'
|
||||||
!=partial('includes/third-party/comments/facebook_comments', {}, {cache: true})
|
!=partial('includes/third-party/comments/facebook_comments', {}, {cache: true})
|
||||||
|
when 'Remark42'
|
||||||
|
!=partial('includes/third-party/comments/remark42', {}, {cache: true})
|
||||||
|
|||||||
34
layout/includes/third-party/comments/remark42.pug
vendored
Normal file
34
layout/includes/third-party/comments/remark42.pug
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
- const { host, siteId, language } = theme.remark42
|
||||||
|
script.
|
||||||
|
var remark_config = {
|
||||||
|
host: '!{host}',
|
||||||
|
site_id: '!{siteId}',
|
||||||
|
components: ['embed'],
|
||||||
|
locale: '!{language}',
|
||||||
|
show_email_subscription: #{theme.remark42.showEmailSubscription},
|
||||||
|
simple_view: #{theme.remark42.simpleView}
|
||||||
|
}
|
||||||
|
|
||||||
|
script.
|
||||||
|
function loadRemark42(){
|
||||||
|
!(function (e, n) {
|
||||||
|
for (var o = 0; o < e.length; o++) {
|
||||||
|
var r = n.createElement('script'),
|
||||||
|
c = '.js',
|
||||||
|
d = n.head || n.body
|
||||||
|
'noModule' in r ? ((r.type = 'module'), (c = '.mjs')) : (r.async = !0),
|
||||||
|
(r.defer = !0),
|
||||||
|
(r.src = remark_config.host + '/web/' + e[o] + c),
|
||||||
|
d.appendChild(r)
|
||||||
|
}
|
||||||
|
})(remark_config.components || ['embed'], document)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
|
||||||
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
|
||||||
|
else loadRemark42()
|
||||||
|
} else {
|
||||||
|
function loadOtherComment () {
|
||||||
|
loadRemark42()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user