feat: 增加Remark42评论系统主题色适应

feat: 增加Remark42主题评论系统自定义显示评论数
This commit is contained in:
pai233 2022-05-11 09:26:19 +08:00
parent 060defa475
commit 41ac7f170c
2 changed files with 13 additions and 0 deletions

View File

@ -362,6 +362,7 @@ remark42:
language: en # https://remark42.com/docs/configuration/frontend/#locales
showEmailSubscription: true
simpleView: false
maxShownComments: 15
# Chat Services
# --------------------------------------

View File

@ -1,11 +1,13 @@
- const { host, siteId, language } = theme.remark42
script.
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
var remark_config = {
host: '!{host}',
site_id: '!{siteId}',
components: ['embed'],
locale: '!{language}',
show_email_subscription: #{theme.remark42.showEmailSubscription},
theme: nowTheme,
simple_view: #{theme.remark42.simpleView}
}
@ -24,6 +26,16 @@ script.
})(remark_config.components || ['embed'], document)
}
function changeRemark42Theme(){
let theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'
window.REMARK42.changeTheme(theme)
}
let themeBtn = document.getElementById('darkmode')
themeBtn.addEventListener('click',()=>{
changeRemark42Theme()
})
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
else loadRemark42()