add related posts to sidebar

This commit is contained in:
John Bowdre 2023-09-12 17:02:42 -05:00
parent b84d0c918c
commit e768c48c05
2 changed files with 20 additions and 0 deletions

View file

@ -4,6 +4,7 @@ description = "while (true) { bugs++; }"
mainSections = ["posts"]
fallBackOgImage = "images/broken-computer.svg"
numberOfFeaturedPosts = 5
numberOfRelatedPosts = 5
author = "codesplice"
indexTitle = ".-. ..- -. - .. -- . - . .-. .-. --- .-."

View file

@ -22,6 +22,25 @@
<hr>
{{ end }}
{{ if isset .Params "series" }}
{{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }}
{{- $relatedLimit := default 8 .Site.Params.numberOfRelatedPosts }}
<h2>More {{ .Params.series }}</h2>
<ul>
{{- range first $relatedLimit $related }}
<li>
<a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title | markdownify }}</a>
</li>
{{ end }}
{{ if gt (len $related) $relatedLimit }}
<li>
<a href="/series/{{ lower .Params.series }}/"><i>See all {{ .Params.series }}</i></a>
</li>
{{ end }}
</ul>
<hr>
{{ end }}
{{- $posts := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{- $featured := default 8 .Site.Params.numberOfFeaturedPosts }}
{{- $featuredPosts := first $featured (where $posts "Params.featured" true)}}