From 1bc3a73f51f94d0dad08d6f640d511a3b6cb6f4d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 22 Nov 2025 12:20:03 +0100 Subject: [PATCH] =?utf8?q?`section`-Template=20f=C3=BCr=20den=20Blog=20auf?= =?utf8?q?=20von=20PaperMod=20=C3=BCbernommen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- layouts/_partials/author.html | 9 ++++ layouts/_partials/post_meta.html | 23 ++++++++++ layouts/baseof.html | 6 ++- layouts/blog/section.html | 74 ++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 layouts/_partials/author.html create mode 100644 layouts/_partials/post_meta.html create mode 100644 layouts/blog/section.html diff --git a/layouts/_partials/author.html b/layouts/_partials/author.html new file mode 100644 index 00000000..8f2758fa --- /dev/null +++ b/layouts/_partials/author.html @@ -0,0 +1,9 @@ +{{- if or .Params.author site.Params.author }} +{{- $author := (.Params.author | default site.Params.author) }} +{{- $author_type := (printf "%T" $author) }} +{{- if (or (eq $author_type "[]string") (eq $author_type "[]interface {}")) }} +{{- (delimit $author ", " ) }} +{{- else }} +{{- $author }} +{{- end }} +{{- end -}} diff --git a/layouts/_partials/post_meta.html b/layouts/_partials/post_meta.html new file mode 100644 index 00000000..ae996bad --- /dev/null +++ b/layouts/_partials/post_meta.html @@ -0,0 +1,23 @@ +{{- $scratch := newScratch }} + +{{- if not .Date.IsZero -}} +{{- $scratch.Add "meta" (slice (printf "%s" (.Date) (.Date | time.Format (default ":date_long" site.Params.DateFormat)))) }} +{{- end }} + +{{- if (.Param "ShowReadingTime") -}} +{{- $scratch.Add "meta" (slice (printf "%s" (i18n "read_time" .ReadingTime | default (printf "%d min" .ReadingTime)))) }} +{{- end }} + +{{- if (.Param "ShowWordCount") -}} +{{- $scratch.Add "meta" (slice (printf "%s" (i18n "words" .WordCount | default (printf "%d words" .WordCount)))) }} +{{- end }} + +{{- if not (.Param "hideAuthor") -}} +{{- with (partial "author.html" .) }} +{{- $scratch.Add "meta" (slice (printf "%s" .)) }} +{{- end }} +{{- end }} + +{{- with ($scratch.Get "meta") }} +{{- delimit . " Â· " | safeHTML -}} +{{- end -}} diff --git a/layouts/baseof.html b/layouts/baseof.html index 0bb66c6e..5558c03e 100644 --- a/layouts/baseof.html +++ b/layouts/baseof.html @@ -9,7 +9,11 @@ {{- partial "breadcrumb.html" . }}
-

{{ .Title }}

+
+ {{- block "title" . }} +

{{ .Title }}

+ {{ end }} +
{{- block "main" . }}{{ end }}
diff --git a/layouts/blog/section.html b/layouts/blog/section.html new file mode 100644 index 00000000..46d76f64 --- /dev/null +++ b/layouts/blog/section.html @@ -0,0 +1,74 @@ +{{- define "title" }} +

+ {{ .Title }} + {{- if (.Param "ShowRssButtonInSectionTermList") }} + {{- $rss := (.OutputFormats.Get "rss") }} + {{- if (eq .Kind `page`) }} + {{- $rss = (.Parent.OutputFormats.Get "rss") }} + {{- end }} + {{- with $rss }} + + + + + + + + {{- end }} + {{- end }} +

+ {{- if .Description }} +
+ {{ .Description }} +
+ {{- end }} +{{- end }} + +{{- define "main" }} +{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} + +{{- if site.Params.ShowAllPagesInArchive }} +{{- $pages = site.RegularPages }} +{{- end }} + +{{- range $pages.GroupByPublishDate "2006" }} +{{- if ne .Key "0001" }} +
+ {{- $year := replace .Key "0001" "" }} +

+ + {{- $year -}} + +

+ {{- range .Pages.GroupByDate "January" }} +
+
+ {{- range .Pages }} + {{- if eq .Kind "page" }} +
+

+ {{- .Title | markdownify }} + {{- if .Draft }} + + + + + + {{- end }} +

+
+ {{- partial "post_meta.html" . -}} +
+
+ {{- end }} + {{- end }} +
+
+ {{- end }} +
+{{- end }} +{{- end }} + +{{- end }}{{/* end main */}} -- 2.39.5