Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support of remark42 comments #742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}, {
Expand Down
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
22 changes: 22 additions & 0 deletions layouts/partials/comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,28 @@
Please enable JavaScript to view the comments powered by <a href="https://giscus.app">Giscus</a>.
</noscript>
{{- end -}}

{{- /* Remark42 Comment System */ -}}
{{- $remark42 := $comment.remark42 | default dict -}}
{{- if $remark42.enable -}}

<script>
var remark_config = {
host: '{{ $remark42.host }}',
site_id: '{{ $remark42.siteId }}',
theme: document.body.getAttribute('theme') === 'dark' ? 'dark' : 'light',
}
</script>

<div id="remark42"></div>

{{- $source := printf "%v/web/embed.js" $remark42.host -}}
{{- dict "Source" $source "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}

<noscript>
Please enable JavaScript to view the comments powered by <a href="https://remark42.com">Remark42</a>.
</noscript>
{{- end -}}
</div>
{{- end -}}

Expand Down