fix: showDateOnlyInArticle

This commit is contained in:
ZhenShuo Leo
2025-10-16 14:15:51 +08:00
parent 8642fc75cf
commit d1f332b9cf

View File

@@ -13,17 +13,19 @@
{{/* Gather partials for this context */}}
{{ $shouldShowDate := false }}
{{ if and (eq $scope "single") (.Params.showDateOnlyInArticle | default (.Site.Params.article.showDateOnlyInArticle | default false)) }}
{{ $shouldShowDate = true }}
{{ end }}
{{/* showDate has higher priority than showDateOnlyInArticle */}}
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ $shouldShowDate = true }}
{{ else }}
{{ $shouldShowDate = false }}
{{ end }}
{{ if (.Params.showDateOnlyInArticle | default (.Site.Params.article.showDateOnlyInArticle | default false)) }}
{{ if (ne $scope "single") }}
{{/* only takes effect when not called directly in the header of single.html */}}
{{ $shouldShowDate = false }}
{{ end }}
{{ end }}
{{ if $shouldShowDate }}
{{ $meta.Add "partials" (slice (partial "meta/date.html" .Date)) }}
{{ end }}