From 41ac7f170c59534f4ff1c0fef2da5dfa25a12d5c Mon Sep 17 00:00:00 2001 From: pai233 Date: Wed, 11 May 2022 09:26:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0Remark42=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E7=B3=BB=E7=BB=9F=E4=B8=BB=E9=A2=98=E8=89=B2=E9=80=82?= =?UTF-8?q?=E5=BA=94=20feat:=20=E5=A2=9E=E5=8A=A0Remark42=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E8=AF=84=E8=AE=BA=E7=B3=BB=E7=BB=9F=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=98=BE=E7=A4=BA=E8=AF=84=E8=AE=BA=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 1 + layout/includes/third-party/comments/remark42.pug | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/_config.yml b/_config.yml index c2b0c2a..81a3222 100644 --- a/_config.yml +++ b/_config.yml @@ -362,6 +362,7 @@ remark42: language: en # https://remark42.com/docs/configuration/frontend/#locales showEmailSubscription: true simpleView: false + maxShownComments: 15 # Chat Services # -------------------------------------- diff --git a/layout/includes/third-party/comments/remark42.pug b/layout/includes/third-party/comments/remark42.pug index d6bae0d..e2c8b8c 100644 --- a/layout/includes/third-party/comments/remark42.pug +++ b/layout/includes/third-party/comments/remark42.pug @@ -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()