blob: 5426f7099f8b88faa063fcb034e923368c97d36b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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" . }}
</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>
|