Skip to content

add comment engine remark42 #100

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

Open
wants to merge 1 commit into
base: main
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
12 changes: 10 additions & 2 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ weight = 4
showReadTime = true # default

[params.comments]
enabled = false # default
engine = "disqus" # more supported engines will be added.
enabled = false # default
engine = "disqus" # valid: disqus | remark42 | ... more to come

[params.remark42] # only needed for remark42 commenting
site_id = "changeme" # REQUIRED
url = "https://my.remark42.url" # REQUIRED
#locale = "en" # select locale
#max_comments = 15 # display that many comments
#simple_view = false # enable simple view (no noticable effect?)
#theme = "light" # "light" | "dark"

# the value of name should be an valid font awesome icon name (brands type)
# https://fontawesome.com/icons?d=gallery&s=brands
Expand Down
30 changes: 29 additions & 1 deletion layouts/partials/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

{{ $enable_comments := .Scratch.Get "enable_comments" }}
{{ if $enable_comments }}
<hr>
{{ if (or (not (isset .Site.Params.Comments "engine")) (eq .Site.Params.Comments.Engine "disqus")) }}
<div class="blog-post-comments">
<div id="disqus_thread">
Expand All @@ -32,5 +33,32 @@
</div>
</div>

{{ else if (eq .Site.Params.Comments.Engine "remark42") }}
<div id="remark42"></div>
<script type="text/javascript">
{{ `// docs see here: https://github.com/umputun/remark42#comments` | safeJS }}
var remark_config = {
host: {{ .Site.Params.remark42.url | default "https://CHANGE.ME.IN.CONFIG.TOML" }},
site_id: {{ .Site.Params.remark42.site_id | default "CHANGE ME IN CONFIG.TOML" }},
components: ['embed'],
url: {{ .Permalink }},
max_shown_comments: {{ .Site.Params.remark42.max_comments | default 15 }},
theme: {{ .Site.Params.remark42.theme | default "light" }},
page_title: {{ .Title }},
locale: {{ .Site.Params.remark42.locale | default "en" }},
show_email_subscription: false,
simple_view: {{ .Site.Params.remark42.simple_view | default false }}
};
</script>
<script>
! 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);
</script>
{{ end }}
{{ end }}
{{ end }}