Fix the case where latestpostcount is missing from configuration.

This commit is contained in:
Tristan Claverie
2017-03-20 20:53:59 +01:00
committed by Alexis Tacnet
parent 80ddd50ee5
commit a9a0b236d3

View File

@@ -8,24 +8,26 @@
</div> </div>
{{ end }} {{ end }}
<div class="posts"> {{ if isset .Site.Params "latestpostcount" }}
{{ $nbPosts := len (where .Data.Pages "Section" "blog") }} <div class="posts">
{{ if gt $nbPosts 0 }} {{ $nbPosts := len (where .Data.Pages "Section" "blog") }}
<div class="page-heading">Latest posts</div> {{ if gt $nbPosts 0 }}
<ul> <div class="page-heading">Latest posts</div>
{{ range (first .Site.Params.latestpostcount (where .Pages "Section" "blog")).GroupByDate "Jan, 2006" "desc" }} <ul>
<li class="groupby">{{ .Key }}</li> {{ range (first .Site.Params.latestpostcount (where .Pages "Section" "blog")).GroupByDate "Jan, 2006" "desc" }}
{{ range .Pages.ByPublishDate }} <li class="groupby">{{ .Key }}</li>
{{ partial "li.html" . }} {{ range .Pages.ByPublishDate }}
{{ partial "li.html" . }}
{{ end }}
{{ end }}
</ul>
{{ if gt $nbPosts .Site.Params.latestpostcount }}
<a href="./blog/" class="see-more">See more ...</a>
{{ end }} {{ end }}
{{ end }} {{ end }}
</ul> </div>
{{ if gt $nbPosts .Site.Params.latestpostcount }}
<a href="./blog/" class="see-more">See more ...</a>
{{ end }}
{{ end }} {{ end }}
</div>
<div class="best-posts"> <div class="best-posts">
{{ $nbPosts := len (where .Data.Pages "Params.best" true) }} {{ $nbPosts := len (where .Data.Pages "Params.best" true) }}