From 6ff9489f84ed43a0b19388be25beb59d5ef1bb3f Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Mon, 29 Nov 2021 01:04:53 +0800 Subject: [PATCH] add param commentOnAllPosts --- exampleSite/config.toml | 11 +++++++---- exampleSite/content/chinese.md | 1 + layouts/_default/single.html | 19 ++++++++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 2565c5c..9bc2700 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -27,17 +27,20 @@ subtitle = "" # Comment decides the comment plugin to be used on your blog site, # e.g. disqus, utterances, ovo. comment = "utterances" -# timeformat, no matter what format to use, make it the second day of Jan. 2006 +# Timeformat, no matter what format to use, make it the second day of Jan. 2006 timeformat = "Jan 02, 2006" # switch for turning on/off lights. switch = ["🌚", "🌝"] -# if true, date of posts will be displayed in the homepage. +# If set true, date of posts will be displayed in the homepage. displayDate = true -# if true, users can select text from your post. +# If set true, users can select text from your post. selectable = true -# custom global font. notice: `globalFontFamily` won't be working +# Custom global font. notice: `globalFontFamily` won't be working # on texts in some special positions like on titles globalFontFamily = 'Helvatica sans-serif' +# If set true, all your posts will use the chosen comment plugin +# except those with a `comment: false` in their front-matter +commentOnAllPosts = false # Disqus configuration [params.disqus] diff --git a/exampleSite/content/chinese.md b/exampleSite/content/chinese.md index 87a7326..16ba62b 100644 --- a/exampleSite/content/chinese.md +++ b/exampleSite/content/chinese.md @@ -3,6 +3,7 @@ author: XJJ title: 中文测试 date: 2021-07-17T10:52:59+08:00 description: +comment: false --- ## 二级标题 diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 845b194..ca8b9d2 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -36,16 +36,17 @@ {{ partial "mermaid.html" . }} {{ end }} -{{ if and .Params.comment (eq .Site.Params.comment "disqus")}} -{{ partial "disqus.html" . }} -{{ end }} +{{ if and .Site.Params.commentOnAllPosts (ne .Params.comment false) }} + {{ if eq .Site.Params.comment "disqus"}} + {{ partial "disqus.html" . }} + {{ end }} -{{ if and .Params.comment (eq .Site.Params.comment "ovo")}} -{{ partial "ovo.html" . }} -{{ end }} + {{ if eq .Site.Params.comment "ovo"}} + {{ partial "ovo.html" . }} + {{ end }} -{{ if and .Params.comment (eq .Site.Params.comment "utterances")}} -{{ partial "utterances.html" . }} + {{ if eq .Site.Params.comment "utterances"}} + {{ partial "utterances.html" . }} + {{ end }} {{ end }} - {{ end }} \ No newline at end of file