From 38bf8a6036df6ece5a2afda72c5c7b4617925b45 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 22 Nov 2025 12:20:03 +0100 Subject: [PATCH] thymeleaf-theme: Added template `archives.html' (based on PaperMod) --- layouts/_partials/author.html | 9 ++++ layouts/_partials/post_meta.html | 23 ++++++++++ layouts/archives.html | 77 ++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 layouts/_partials/author.html create mode 100644 layouts/_partials/post_meta.html create mode 100644 layouts/archives.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/archives.html b/layouts/archives.html new file mode 100644 index 00000000..229ebc29 --- /dev/null +++ b/layouts/archives.html @@ -0,0 +1,77 @@ +{{- 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 -}} + +  {{ len .Pages }} +

+ {{- 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