From f0506acd6f70da636b8fdb23439c85bbf2392b40 Mon Sep 17 00:00:00 2001 From: Arne Rief Date: Sat, 16 Aug 2025 22:42:03 +0200 Subject: HTML templates done --- layouts/partials/list/pagination.html | 28 ++++++++++++++++++ layouts/partials/list/post-card.html | 45 +++++++++++++++++++++++++++++ layouts/partials/list/recent-posts.html | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 layouts/partials/list/pagination.html create mode 100644 layouts/partials/list/post-card.html create mode 100644 layouts/partials/list/recent-posts.html (limited to 'layouts/partials/list') diff --git a/layouts/partials/list/pagination.html b/layouts/partials/list/pagination.html new file mode 100644 index 0000000..47d90ff --- /dev/null +++ b/layouts/partials/list/pagination.html @@ -0,0 +1,28 @@ +{{- $paginator := . }} +{{- if gt $paginator.TotalPages 1 }} + +{{- end }} diff --git a/layouts/partials/list/post-card.html b/layouts/partials/list/post-card.html new file mode 100644 index 0000000..12eada4 --- /dev/null +++ b/layouts/partials/list/post-card.html @@ -0,0 +1,45 @@ +{{- $post := . }} +
+
+

+ + {{ $post.Title }} + +

+
+ + {{- with $post.ReadingTime }} +

+ {{ lang.Translate "list.reading_time" . | default (printf "Estimated reading time: %s min" .) }} +

+ {{- end }} +
+
+ + {{- with $post.Summary }} +
+ {{ . }} +
+ {{- end }} + + {{- with $post.Params.tags }} +
+
    + {{- range first 3 . }} +
  • + #{{ . }} +
  • + {{- end }} + {{- if gt (len .) 3 }} +
  • + + +{{ sub (len .) 3 }} {{ lang.Translate "common.more" | default "more" }} + +
  • + {{- end }} +
+
+ {{- end }} +
diff --git a/layouts/partials/list/recent-posts.html b/layouts/partials/list/recent-posts.html new file mode 100644 index 0000000..c1075e2 --- /dev/null +++ b/layouts/partials/list/recent-posts.html @@ -0,0 +1,50 @@ +{{- /* +List of Recent Posts. Accepts a dict with the following optional parameters: + +@context {int} count: Number of posts to display (default: 10). +@context {string} title: Section title (default: "Recent Articles"). +@context {bool} show_view_all: Whether to show "View All Posts" link (default: true). + +@example: {{ partial "list/recent-posts.html" (dict "count" 20 "title" "Latest updates" "show_view_all" true) }} +*/ -}} + +{{- $count := .count | default 10 -}} +{{- $title := .title | default (lang.Translate "posts.recent" | default "Recent Articles") -}} +{{- $showViewAll := .show_view_all | default true -}} + +
+
+

+ {{ $title }} +

+
+ + {{- /* Get published 10 most recent posts */ -}} + {{- $recentPosts := where site.RegularPages "Date" "!=" nil }} + {{- $recentPosts = where $recentPosts ".Date" "le" now }} + {{- $recentPosts = first $count $recentPosts }} + + {{- if $recentPosts }} +
+
    + {{- range $recentPosts }} +
  • + {{- partial "list/post-card.html" . }} +
  • + {{- end }} +
+ + {{- if $showViewAll }} + + {{ lang.Translate "posts.view_all" | default "View all posts" }} + + {{- end }} +
+ {{ else }} +
+

+ {{ lang.Translate "list.empty" | default "No posts in this section." }} +

+
+ {{- end }} +
-- cgit v1.2.3