From 5c47607d23d31bda44f2f660df372a924daa2381 Mon Sep 17 00:00:00 2001 From: Reorx Date: Tue, 31 May 2022 22:41:10 +0800 Subject: [PATCH] support specifying comment system in both config and front matter in config: site.Params.defaultCommentSystems in front matter: pageCommentSystems --- layouts/partials/comments.html | 30 ++++++++++++++++++++------- layouts/partials/disqus.html | 27 ++++++++++++++++++++++++ layouts/partials/disqus_script.html | 27 ------------------------ layouts/partials/telegram_widget.html | 5 +++-- 4 files changed, 52 insertions(+), 37 deletions(-) delete mode 100644 layouts/partials/disqus_script.html diff --git a/layouts/partials/comments.html b/layouts/partials/comments.html index a9d5391..36460f4 100644 --- a/layouts/partials/comments.html +++ b/layouts/partials/comments.html @@ -1,13 +1,27 @@ {{- /* You can add your own layouts/comments.html to override this file */ -}} -{{- with site.Params.commentSystem.remark42 -}} - {{- partial "remark42.html" . }} -{{- end -}} +{{- $pageCommentSystems := .Param "pageCommentSystems"}} +{{- if not $pageCommentSystems }} + {{- $pageCommentSystems = site.Params.defaultCommentSystems }} +{{- end }} -{{- with site.Params.commentSystem.telegramWidget -}} - {{- partial "telegram_widget.html" . }} -{{- end -}} +{{- $page := . -}} +{{- with site.Params.commentSystems -}} + {{- if $pageCommentSystems.remark42 -}} + {{- with .remark42 -}} + {{- partial "remark42.html" . }} + {{- end -}} + {{- end -}} -{{- with site.Params.commentSystem.disqus -}} - {{- partial "disqus.html" . }} + {{- if $pageCommentSystems.telegramWidget -}} + {{- with .telegramWidget -}} + {{- partial "telegram_widget.html" . }} + {{- end -}} + {{- end -}} + + {{- if $pageCommentSystems.disqus -}} + {{- with .disqus -}} + {{- partial "disqus.html" (dict "page" $page "disqus" .) }} + {{- end -}} + {{- end -}} {{- end -}} diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html index dc86fc2..e6b9b33 100644 --- a/layouts/partials/disqus.html +++ b/layouts/partials/disqus.html @@ -1,3 +1,30 @@
+ + diff --git a/layouts/partials/disqus_script.html b/layouts/partials/disqus_script.html deleted file mode 100644 index 4840d14..0000000 --- a/layouts/partials/disqus_script.html +++ /dev/null @@ -1,27 +0,0 @@ - diff --git a/layouts/partials/telegram_widget.html b/layouts/partials/telegram_widget.html index 430c72e..1f614c7 100644 --- a/layouts/partials/telegram_widget.html +++ b/layouts/partials/telegram_widget.html @@ -1,4 +1,3 @@ -{{- with site.Params.commentSystem.telegramWidget }}
-{{- end }}