-
-
Notifications
You must be signed in to change notification settings - Fork 580
Expand file tree
/
Copy pathrecentBlogPosts.html
More file actions
44 lines (44 loc) · 2.25 KB
/
Copy pathrecentBlogPosts.html
File metadata and controls
44 lines (44 loc) · 2.25 KB
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
{{ $recentPostsPath := .Site.Params.footer.recentPosts.path | default "blogs" }}
{{- /* Get the blogs section page */ -}}
{{ $blogsSection := site.GetPage "section" $recentPostsPath }}
{{ $allSectionPosts := slice }}
{{ if $blogsSection }}
{{ $allSectionPosts = $blogsSection.RegularPages }}
{{ end }}
{{ $currentNumOfrecentPosts := len $allSectionPosts }}
{{ if and (gt $currentNumOfrecentPosts 0) (.Site.Params.footer.recentPosts.enable | default false) }}
<div class="container py-3" id="recent-posts">
{{ $recentPostsCount := .Site.Params.footer.recentPosts.count | default 3 }}
{{ $recentPosts := $allSectionPosts | first $recentPostsCount }}
<div class="h3 text-center text-secondary py-3">
{{ .Site.Params.footer.recentPosts.title | default (i18n "recent_posts") }}
</div>
<div class="row justify-content-center">
{{ range $recentPosts }}
<div class="col-lg-4 col-md-6 pt-2">
<div class="card h-100">
{{ if and (not (.Site.Params.footer.recentPosts.disableFeaturedImage | default false)) (.Params.image) }}
<div class="card-header">
<a href="{{ .RelPermalink }}">
<img src="{{ .Params.image }}" class="card-img-top" alt="{{ .Title }}" loading="lazy">
</a>
</div>
{{ end }}
<div class="card-body bg-transparent p-3 shadow-sm">
<a href="{{ .RelPermalink }}" class="primary-font card-title">
<h5 class="card-title bg-transparent" title="{{ .Title }}">{{ .Title | truncate 25 }}</h5>
</a>
<div class="card-text secondary-font">
<p>{{ .Summary | truncate 300}}</p>
</div>
</div>
<div class="mt-auto card-footer">
<span class="float-start">{{ .Date | time.Format (":date_long" | default "January 2, 2006") }}</span>
<a href="{{ .RelPermalink }}" class="float-end btn btn-outline-info btn-sm">{{ .Site.Params.terms.read | default (i18n "read") }}</a>
</div>
</div>
</div>
{{ end }}
</div>
</div>
{{ end }}