~alanorth/hugo-theme-bootstrap4-blog

26e0a9a25916cea4292c478864348e5f3cd40bc5 — Alan Orth 2 years ago 1faeef4
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
1 files changed, 1 insertions(+), 1 deletions(-)

M layouts/partials/recent.html
M layouts/partials/recent.html => layouts/partials/recent.html +1 -1
@@ 2,7 2,7 @@
    <h4>{{ i18n "recentPosts" }}</h4>
    <ol class="list-unstyled">
{{ $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>
{{ end }}
    </ol>