diff --git a/README.md b/README.md index d0de81064..fd8a3d002 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ I hope you will LoveIt ❤️! * **Commento** comment system supported by [Commento](https://commento.io/) * **utterances** comment system supported by [utterances](https://utteranc.es/) * **giscus** comment system supported by [giscus](https://giscus.app/) +* **Remark42** comment system supported by [Remark42](https://remark42.com/) ### Extended Features diff --git a/assets/js/theme.js b/assets/js/theme.js index 6f2f730d1..8b530166c 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -902,6 +902,17 @@ var Theme = /*#__PURE__*/function () { this.switchThemeEventSet.add(this._giscusOnSwitchTheme); } + + if (this.config.comment.remark42) { + this._remark42OnSwitchTheme = function () { + if (_this11.isDark) { + window.REMARK42.changeTheme('dark'); + } else { + window.REMARK42.changeTheme('light'); + } + } + this.switchThemeEventSet.add(this._remark42OnSwitchTheme); + } } } }, { diff --git a/config.toml b/config.toml index 7dd3b9def..21610725f 100644 --- a/config.toml +++ b/config.toml @@ -500,6 +500,10 @@ lazyLoading = false lightTheme = "light" darkTheme = "dark" + [params.page.comment.remark42] + enable = false + host="https://demo.remark42.com" + siteId="remark" # Third-party library config # 第三方库配置 [params.page.library] diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index 2a52864e8..844b0c288 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -146,6 +146,28 @@ Please enable JavaScript to view the comments powered by Giscus. {{- end -}} + + {{- /* Remark42 Comment System */ -}} + {{- $remark42 := $comment.remark42 | default dict -}} + {{- if $remark42.enable -}} + + + +
+ + {{- $source := printf "%v/web/embed.js" $remark42.host -}} + {{- dict "Source" $source "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} + + + {{- end -}} {{- end -}}