1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-11-24 21:20:17 +01:00

layouts/partials/recent.html: Only list "Regular" pages

This makes Hugo only list "Regular" pages in the sidebar. Otherwise
if you have very few posts, for example, you might see one entry in
the list called "Posts".

See: https://gohugo.io/functions/where/#mainsections
This commit is contained in:
Alan Orth 2019-05-26 10:28:31 +03:00
parent 1faeef487b
commit 26e0a9a259
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -2,7 +2,7 @@
<h4>{{ i18n "recentPosts" }}</h4> <h4>{{ i18n "recentPosts" }}</h4>
<ol class="list-unstyled"> <ol class="list-unstyled">
{{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }} {{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }}
{{ range first $num_recent_posts (where .Site.Pages "Section" "in" .Site.Params.mainSections) }} {{ range first $num_recent_posts (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
<li><a href="{{.RelPermalink}}">{{.Title | markdownify }}</a></li> <li><a href="{{.RelPermalink}}">{{.Title | markdownify }}</a></li>
{{ end }} {{ end }}
</ol> </ol>