From 5c47607d23d31bda44f2f660df372a924daa2381 Mon Sep 17 00:00:00 2001 From: Reorx Date: Tue, 31 May 2022 22:41:10 +0800 Subject: support specifying comment system in both config and front matter in config: site.Params.defaultCommentSystems in front matter: pageCommentSystems --- layouts/partials/comments.html | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'layouts/partials/comments.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 -}} + + {{- if $pageCommentSystems.telegramWidget -}} + {{- with .telegramWidget -}} + {{- partial "telegram_widget.html" . }} + {{- end -}} + {{- end -}} -{{- with site.Params.commentSystem.disqus -}} - {{- partial "disqus.html" . }} + {{- if $pageCommentSystems.disqus -}} + {{- with .disqus -}} + {{- partial "disqus.html" (dict "page" $page "disqus" .) }} + {{- end -}} + {{- end -}} {{- end -}} -- cgit v1.2.3