diff options
author | Wang Chucheng <me@wangchucheng.com> | 2021-04-11 14:01:18 +0300 |
---|---|---|
committer | Wang Chucheng <me@wangchucheng.com> | 2021-04-11 14:57:08 +0300 |
commit | ebf560f9f484c5027a5fc9f418510d363a6bed3e (patch) | |
tree | 463ea6446649fd0611742a45844993a6c842e9c1 | |
parent | d07e1032454d90d3282e6d5caa5899a244e59ec6 (diff) |
feat: recursive enableComment param
BREAKING CHANGES: Param `comment.platform` in params.yaml is deprecated.
-rw-r--r-- | assets/js/eureka.js | 5 | ||||
-rw-r--r-- | exampleSite/config/_default/params.yaml | 24 | ||||
-rw-r--r-- | layouts/partials/comment.html | 23 |
3 files changed, 37 insertions, 15 deletions
diff --git a/assets/js/eureka.js b/assets/js/eureka.js index 4f9778a..5aa52a7 100644 --- a/assets/js/eureka.js +++ b/assets/js/eureka.js @@ -148,7 +148,10 @@ function getcolorscheme() { } {{/* Utterances */}} -{{ $enableUtterances := and (eq .Site.Params.comment.platform "utterances") (eq .Site.Params.comment.utterances.theme "eureka") }} +{{/* Deprecation warning(v1.0.0) starts */}} +{{- $commentHandler := .Site.Params.comment.handler | default .Site.Params.comment.platform }} +{{/* Deprecation warning(v1.0.0) ends */}} +{{ $enableUtterances := and (eq $commentHandler "utterances") (eq .Site.Params.comment.utterances.theme "eureka") }} {{- if $enableUtterances }} function switchUtterancesTheme(theme) { const message = { diff --git a/exampleSite/config/_default/params.yaml b/exampleSite/config/_default/params.yaml index f930a4d..5eaeaf2 100644 --- a/exampleSite/config/_default/params.yaml +++ b/exampleSite/config/_default/params.yaml @@ -41,21 +41,21 @@ math: comment: # Options: disqus, commento and utterances. - platform: + handler: - disqus: - shortname: + # disqus: + # shortname: - commento: - # If self-hosting, please enter the url (e.g. https://commento.example.com) here. Otherwise leave empty. - url: + # utterances: + # # Browse https://utteranc.es/ to see the options available. + # # If you want the color scheme of utterances to follow eureka's, you can set `theme: eureka`. + # repo: + # issue-term: + # theme: - utterances: - # Browse https://utteranc.es/ to see the options available. - # If you want the color scheme of utterances to follow eureka's, you can set `theme: eureka'. - repo: - issue-term: - theme: + # commento: + # # If self-hosting, please enter the url (e.g. https://commento.example.com) here. Otherwise leave empty. + # url: diagram: handler: mermaid diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index c2161c3..d182be7 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -1,3 +1,22 @@ -{{ if .Site.Params.comment.platform }} - {{ partial (printf "comment/%s" .Site.Params.comment.platform) . }} +{{/* Deprecation warning(v1.0.0) starts */}} +{{- if .Site.Params.comment.platform }} + {{- warnf "Param `comment.platform` in params.yaml is deprecated and will be removed in Eureka v1.0.0. Please use `comment.handler` instead." }} +{{- end }} +{{- $commentHandler := .Site.Params.comment.handler | default .Site.Params.comment.platform }} +{{/* Deprecation warning(v1.0.0) ends */}} + +{{- $enableComment := false }} + +{{- if $commentHandler }} +{{- $bundles := partial "utils/get-bundles" . }} +{{- $enableComment = true }} +{{- range $bundles.Reverse }} +{{- if and (ne .Params.enableComment nil) (ne .Params.enableComment "") }} +{{- $enableComment = .Params.enableComment }} +{{- end }} +{{- end }} +{{- end }} + +{{ if $enableComment }} + {{ partial (printf "comment/%s" $commentHandler) . }} {{ end }}
\ No newline at end of file |