From f84d590023d7ad5e46d288325a697c074a7e39ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Sun, 30 Oct 2022 21:04:08 +0800 Subject: [PATCH 1/3] :bug: Fixed the comment setting in front matter. --- exampleSite/content/post/no-header-title.md | 10 ++++++---- layouts/_default/baseof.html | 6 ++++-- layouts/partials/head/config.html | 2 +- layouts/partials/post/header.html | 4 ++-- layouts/partials/widgets.html | 4 +++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/exampleSite/content/post/no-header-title.md b/exampleSite/content/post/no-header-title.md index 13c85f7..7a75e84 100644 --- a/exampleSite/content/post/no-header-title.md +++ b/exampleSite/content/post/no-header-title.md @@ -1,10 +1,10 @@ --- -title: "没有H1-6标题头的文章" -description: "用于测试在没有H1-6标题头时,文章的目录导航是否会直接关闭。" +title: "没有H1-6标题头和评论的文章" +description: "用于测试在没有H1-6标题头时,文章的目录导航是否会直接关闭,并关闭评论功能。" keywords: "toc,header" date: 2022-10-06T09:02:26+08:00 -lastmod: 2022-10-06T09:02:26+08:00 +lastmod: 2022-10-30T21:03:16+08:00 categories: - 示例 @@ -12,12 +12,14 @@ tags: - toc - 标题 +comment: + enable: false url: "post/no-header-title.html" --- 刘慈欣2018克拉克奖获奖感言(部分内容节选)。 -> 用于测试在没有H1-6标题头时,文章的目录导航是否会直接关闭。 +> 用于测试在没有H1-6标题头时,文章的目录导航是否会直接关闭,并关闭评论功能。 diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 7111efc..8db7191 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,6 +1,8 @@ {{- range $k, $v := (partialCached "init.html" .) -}} - {{- $.Scratch.Set $k $v -}} +{{- $.Scratch.Set $k $v -}} {{- end -}} +{{ $commentEnable := .Params.comment.enable | default .Site.Params.comments.enable }} +{{ .Scratch.Set "isComment" $commentEnable }} @@ -29,7 +31,7 @@
{{- block "main" . }}{{- end }} - {{- if .IsPage }} + {{- if and .IsPage $commentEnable }} {{- partialCached "comments.html" . }} {{- end }}
diff --git a/layouts/partials/head/config.html b/layouts/partials/head/config.html index 60fb5b4..c4b9b5b 100644 --- a/layouts/partials/head/config.html +++ b/layouts/partials/head/config.html @@ -1,7 +1,7 @@ {{- $pageCfg := dict "isHome" .IsHome "isPage" .IsPage - "comments" (.Params.comments | default .Site.Params.comments.enable) + "comments" (.Scratch.Get "isComment") "permalink" (.Page.Permalink | absURL) "path" (.Page.Permalink | path.Base) "title" .Page.Title diff --git a/layouts/partials/post/header.html b/layouts/partials/post/header.html index ca348a8..11675cb 100644 --- a/layouts/partials/post/header.html +++ b/layouts/partials/post/header.html @@ -32,7 +32,7 @@ {{ if .Site.Params.waline.pageView }} {{ partial "post/header_meta/views.html" . }} {{ end }} - {{ if .Site.Params.waline.comment }} + {{ if and (.Scratch.Get "isComment") .Site.Params.waline.comment }} {{ partial "post/header_meta/comments.html" . }} {{ end }} @@ -43,7 +43,7 @@ {{ partial "post/header_meta/words.html" . }} {{ partial "post/header_meta/readtime.html" . }} {{ partial "post/header_meta/views.html" . }} - {{ if .Site.Params.waline.comment }} + {{ if and (.Scratch.Get "isComment") .Site.Params.waline.comment }} {{ partial "post/header_meta/comments.html" . }} {{ end }} diff --git a/layouts/partials/widgets.html b/layouts/partials/widgets.html index 66b6af1..2cddedc 100644 --- a/layouts/partials/widgets.html +++ b/layouts/partials/widgets.html @@ -1,7 +1,9 @@
+ {{ if .Scratch.Get "isComment" }}
-
+
+ {{ end }} {{ if .Site.Params.footer.translate }}
From 51221f0f91b720a7c87c720ff0431a247958ab87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Sun, 30 Oct 2022 21:12:01 +0800 Subject: [PATCH 2/3] :memo: Upgrade the README content about post front matter. --- README.md | 6 ++++-- README.zh.md | 5 +++-- archetypes/default.md | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6ffd465..edb6714 100644 --- a/README.md +++ b/README.md @@ -112,10 +112,12 @@ tags: #expand: true # It's means that will redirecting to external links #extlink: -# Switch to enabled or disabled comment plugins in this post +# Disabled comment plugins in this post #comment: # enable: false -# Enable table of content +# Disable table of content int this post +# Notice: By default will automatic build table of content +# with h2-h4 title in post and without other settings #toc: false # Absolute link for visit #url: "{{ lower .Name }}.html" diff --git a/README.zh.md b/README.zh.md index 5ee408e..32340ec 100644 --- a/README.zh.md +++ b/README.zh.md @@ -120,10 +120,11 @@ tags: #expand: true # 外部链接地址,访问时直接跳转 #extlink: -# 在当前页面开启或关闭评论功能 +# 在当前页面关闭评论功能 #comment: # enable: false -# 开启文章目录功能 +# 关闭当前页面目录功能 +# 注意:正常情况下文章中有H2-H4标题会自动生成目录,无需额外配置 #toc: false # 绝对访问路径 #url: "{{ lower .Name }}.html" diff --git a/archetypes/default.md b/archetypes/default.md index b317672..abed622 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -27,12 +27,12 @@ tags: # 外部链接地址,访问时直接跳转 # It's means that will redirecting to external links #extlink: -# 在当前页面开启或关闭评论功能 -# Switch to enabled or disabled comment plugins in this post +# 在当前页面关闭评论功能 +# Disabled comment plugins in this post #comment: # enable: false -# 开启文章目录功能 -# Enable table of content +# 关闭文章目录功能 +# Disable table of content #toc: false # 绝对访问路径 # Absolute link for visit From 54ada081c70fcb9410920d99ef55617e6c4fe289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Sun, 30 Oct 2022 21:19:34 +0800 Subject: [PATCH 3/3] :bug: Fixed the busuanzi post view counter in home page. --- layouts/partials/post/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/post/header.html b/layouts/partials/post/header.html index 11675cb..b482c8e 100644 --- a/layouts/partials/post/header.html +++ b/layouts/partials/post/header.html @@ -29,7 +29,7 @@ {{ partial "post/header_meta/categories.html" . }} {{ if and $.IsHome (not (isset .Params "extlink")) }}