I’m trying to do a simple take on this that prioritizes explicitly specified related posts and fills the rest of the spots with the generated Related posts but also finding it’s taking me a frustratingly long time to get it to work.
It’s clear that mapping these URLs to the Page object won’t work because the apply doesn’t work with GetPage (would appreciate if this were explicitly stated in the documentation). I’m now trying to do it the other way where I map the Pages returned from .Site.RegularPages.Related to their .RelPermalink but can’t seem to find a way to do this. Am I missing something?
With this code I get a couple of specific pages (contact, about) at the top of the list, followed by the first three related pages (or none if there aren’t any related pages).
{{- $specificPages := slice -}}
{{- $specificPlusRelatedPages := slice -}}
{{- with .Site.GetPage "/page/contact.md" -}}
{{- $specificPages = $specificPages | append . -}}
{{- end -}}
{{- with .Site.GetPage "/page/about.md" -}}
{{- $specificPages = $specificPages | append . -}}
{{- end -}}
{{- $relatedPages := .Site.RegularPages.Related . | first 3 -}}
{{- with $relatedPages }}
{{- $specificPlusRelatedPages = $specificPages | append . -}}
{{- end -}}
{{- with $specificPlusRelatedPages }}
<ul>
{{- range . }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{- end }}
</ul>
{{ end -}}