Skip to content

Commit

Permalink
feat: add support for remark42 comment engine (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlhg authored Jan 20, 2024
1 parent 4f68482 commit 559137d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
17 changes: 17 additions & 0 deletions config-examples/en/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,23 @@ uglyURLs = false
giscusLang = "en"
# Note: https://giscus.app

# Remark42
enableRemark42 = false
remark42Host = ""
remark42SiteId = "remark"
remark42Url = ""
remark42Components = ["embed"]
remark42MaxShownComments = 15
remark42MaxLastComments = 15
remark42Theme = "light"
remark42PageTitle = ""
remark42Locale = "en"
remark42ShowEmailSubscription = true
remark42ShowRssSubscription = true
remark42SimpleView = false
remark42NoFooter = false
# Note: https://remark42.com/docs/configuration/frontend/


######################################
# Google Analytics
Expand Down
17 changes: 17 additions & 0 deletions config-examples/zh-cn/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,23 @@ uglyURLs = false
giscusLang = "zh-CN"
# 说明:https://giscus.app/zh-CN

# Remark42
enableRemark42 = false
remark42Host = ""
remark42SiteId = "remark"
remark42Url = ""
remark42Components = ["embed"]
remark42MaxShownComments = 15
remark42MaxLastComments = 15
remark42Theme = "light"
remark42PageTitle = ""
remark42Locale = "zh"
remark42ShowEmailSubscription = true
remark42ShowRssSubscription = true
remark42SimpleView = false
remark42NoFooter = false
# 说明:https://remark42.com/docs/configuration/frontend/


######################################
# Google Analytics
Expand Down
17 changes: 17 additions & 0 deletions config-examples/zh-tw/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,23 @@ uglyURLs = false
giscusLang = "zh-TW"
# 說明:https://giscus.app/zh-TW

# Remark42
enableRemark42 = false
remark42Host = ""
remark42SiteId = "remark"
remark42Url = ""
remark42Components = ["embed"]
remark42MaxShownComments = 15
remark42MaxLastComments = 15
remark42Theme = "light"
remark42PageTitle = ""
remark42Locale = "zh-tw"
remark42ShowEmailSubscription = true
remark42ShowRssSubscription = true
remark42SimpleView = false
remark42NoFooter = false
# 說明:https://remark42.com/docs/configuration/frontend/


######################################
# Google Analytics
Expand Down
5 changes: 5 additions & 0 deletions layouts/partials/components/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@
{{ if .Site.Params.enableGiscus }}
<div id="giscus"></div>
{{ end }}

{{ if .Site.Params.enableRemark42 }}
<div id="remark42"></div>
{{ end }}

{{ end }}
{{ end }}
15 changes: 15 additions & 0 deletions layouts/partials/third-party/remark42.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
var remark_config = {
host: '{{ .Site.Params.remark42Host }}',
site_id: {{ .Site.Params.remark42SiteId }},
components: {{ .Site.Params.remark42Components }},
max_shown_comments: {{ .Site.Params.remark42MaxShowingComments }},
theme: '{{ .Site.Params.remark42Theme }}',
page_title: '{{ .Site.Params.remark42PageTitle }}',
locale: '{{ .Site.Params.remark42Locale }}',
show_email_subscription: {{ .Site.Params.remark42ShowEmailSubscription }},
simple_view: {{ .Site.Params.remark42SimpleView }},
no_footer: {{ .Site.Params.remark42NoFooter }}
}
</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>
4 changes: 4 additions & 0 deletions layouts/partials/third-party/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
{{ partial "third-party/giscus.html" . }}
{{ end }}

{{ if .Site.Params.enableRemark42 }}
{{ partial "third-party/remark42.html" . }}
{{ end }}

{{ end }}
{{ end }}

Expand Down

0 comments on commit 559137d

Please sign in to comment.