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/recent-posts.html | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 layouts/partials/list/recent-posts.html (limited to 'layouts/partials/list/recent-posts.html') 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