From ed02880e29f8dea56b7276978d3822f25d5f15e9 Mon Sep 17 00:00:00 2001 From: hossainemruz Date: Thu, 28 Oct 2021 21:04:46 +0600 Subject: [PATCH] Make comment section backward compatible with old config Signed-off-by: hossainemruz --- layouts/_default/single.html | 29 +++++++++++++++-------------- layouts/partials/disqus.html | 7 ++++++- layouts/partials/valine.html | 26 +++++++++++++------------- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 3ba95bd..2423a98 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -156,22 +156,23 @@ {{ partial "navigators/next-prev-navigator.html" . }}
- - {{ $commentEnabled:= false }} - {{ if or site.Params.features.comment.enabled site.DisqusShortname }} - {{ $commentEnabled = true }} - {{ end }} - {{ if $commentEnabled }} - {{ with site.Params.features.comment }} - - {{ if or .disqus.shortName site.DisqusShortname }} - {{ partial "disqus.html" . }} - - {{ else if .valine }} - {{ partial "valine.html" . }} - {{ end }} + + {{ with site.Params.features.comment }} + {{ if .enable }} + + {{ if .disqus.shortName }} + {{ partial "disqus.html" . }} + + {{ else if .valine }} + {{ partial "valine.html" . }} {{ end }} + {{ end }} {{ end }} + + {{ if site.DisqusShortname }} + {{ partial "disqus.html" . }} + {{ end }} + diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html index 71fef21..4ccd9e2 100644 --- a/layouts/partials/disqus.html +++ b/layouts/partials/disqus.html @@ -1,3 +1,8 @@ +{{ $disqusShortName := site.DisqusShortname }} +{{ if site.Params.features.disqus.shortName }} + {{ $disqusShortName = site.Params.features.disqus.shortName }} +{{ end }} +
- + \ No newline at end of file + new Valine({ + el: "#vcomments", + appId: "{{ .valine.appId }}", + appKey: "{{ .valine.appKey }}", + avatar: "{{ .valine.avatar }}", + placeholder: "{{ .valine.placeholder }}", + visitor: "{{ .valine.visitor }}", + lang: "{{ .valine.lang }}", + recordIP: "{{ .valine.recordIP }}", + enableQQ: "{{ .valine.enableQQ }}", + }); +