add related posts to sidebar

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

View file

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

View file

@ -22,6 +22,25 @@
<hr> <hr>
{{ end }} {{ 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 }} {{- $posts := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{- $featured := default 8 .Site.Params.numberOfFeaturedPosts }} {{- $featured := default 8 .Site.Params.numberOfFeaturedPosts }}
{{- $featuredPosts := first $featured (where $posts "Params.featured" true)}} {{- $featuredPosts := first $featured (where $posts "Params.featured" true)}}