diff options
| author | Arne Rief <riearn@proton.me> | 2026-01-09 12:24:05 +0100 |
|---|---|---|
| committer | Arne Rief <riearn@proton.me> | 2026-01-09 12:24:05 +0100 |
| commit | f8541ef965ca22e746b523eb418e47cb4f78f2d8 (patch) | |
| tree | 49e1540ed42595a44196817eadf97337587a2aea /layouts/_partials/list/recent-posts.html | |
| parent | 038054b8206a9c25e84adeb0f0f355abd22d6143 (diff) | |
Upgrade to new template system from Hugo v0.146.0
Diffstat (limited to 'layouts/_partials/list/recent-posts.html')
| -rw-r--r-- | layouts/_partials/list/recent-posts.html | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/layouts/_partials/list/recent-posts.html b/layouts/_partials/list/recent-posts.html new file mode 100644 index 0000000..464e9f7 --- /dev/null +++ b/layouts/_partials/list/recent-posts.html @@ -0,0 +1,45 @@ +{{- /* +List of specified number of the most recent and published 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 -}} +<section class="recent-posts" aria-labelledby="recent-posts-heading"> + <header class="recent-posts__header"> + <h2 id="recent-posts-heading" class="recent-posts__title"> + {{ $title }} + </h2> + </header> + + {{- $recentPosts := where site.RegularPages "Params.excludeFromLists" "!=" true | first $count }} + {{- if $recentPosts }} + <div class="recent-posts__content"> + <ul class="recent-posts__list" role="list"> + {{- range $recentPosts }} + <li class="recent-posts__list-item"> + {{- partial "list/post-card.html" (dict "post" . "show_section" true) }} + </li> + {{- end }} + </ul> + + {{- if $showViewAll }} + {{- with site.GetPage "/all-posts"}} + <a href="{{ .RelPermalink }}" class="recent-posts__view-all-link"> + {{ lang.Translate "posts_all_view" | default "View all posts" }} ยป + </a> + {{- end }} + {{- end }} + </div> + {{ else }} + <p class="recent-posts__empty-message"> + {{ lang.Translate "list_empty" | default "No posts in this section." }} + </p> + {{- end }} +</section> |
