set a limit for how many related series posts should be displayed

This commit is contained in:
John Bowdre 2021-12-16 19:55:03 -06:00
parent 1050f87b97
commit 09c9a8273b
3 changed files with 13 additions and 2 deletions

View file

@ -63,6 +63,7 @@ comments = true
# Maximum number of recent posts.
numberOfRecentPosts = 6
numberOfRelatedPosts = 6
# Maximum number of featured posts.
numberOfFeaturedPosts = 4

View file

@ -1,9 +1,13 @@
{{ if isset .Params "series" }}
{{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }}
{{- $relatedLimit := default 8 .Params.numberOfRelatedPosts }}
<h2 class="post_related">{{ T "series_posts" }}{{ .Params.series }}</h2>
<ul>
{{ range $related }}
{{ range first $relatedLimit $related }}
<li><a href="{{ .Permalink }}" class="nav-link" title="{{ .Title }}">{{ .Title }}</a></li>
{{ end }}
{{ if gt (len $related) $relatedLimit }}
<li><a href="/series/{{ lower .Params.series }}/">See all {{ .Params.series }}</a></li>
{{ end }}
</ul>
{{ end }}

View file

@ -42,13 +42,19 @@
{{- end }}
{{ if (and ($relatedInSidebar) (isset .Params "series") ) }}
{{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }}
{{- $relatedLimit := default 8 $s.numberOfRelatedPosts }}
<h2 class="mt-4">{{ T "series_posts" }}{{ .Params.series }}</h2>
<ul>
{{ range $related }}
{{ range first $relatedLimit $related }}
<li>
<a href="{{ .Permalink }}" class="nav-link" title="{{ .Title }}">{{ .Title }}</a>
</li>
{{ end }}
{{ if gt (len $related) $relatedLimit }}
<li>
<a href="/series/{{ lower .Params.series }}/">See all {{ .Params.series }}</a>
</li>
{{ end }}
</ul>
{{ end }}