Files

31 lines
1.3 KiB
HTML

{{- /* related-pages.html — renders the current page's relatedPages front-matter
(a list of slugs) as cards. Matches by .Slug or file base name. */ -}}
{{- $current := . -}}
{{- $related := .Params.relatedPages -}}
{{- if $related -}}
{{- $found := slice -}}
{{- range $slug := $related -}}
{{- range $p := $current.Site.Pages -}}
{{- if and (ne $p $current) (not $p.IsHome) -}}
{{- if or (eq $p.Slug $slug) (and $p.File (eq $p.File.ContentBaseName $slug)) -}}
{{- $found = $found | append $p -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- with $found -}}
<section class="site-container section" aria-labelledby="related-heading">
<h2 id="related-heading" class="text-xl font-bold">{{ i18n "relatedPages" }}</h2>
<div class="mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{{- range . -}}
<a href="{{ .RelPermalink }}" class="card card-hover block no-underline">
<span class="badge-primary">{{ .LinkTitle }}</span>
<p class="mt-2 text-sm text-secondary/70">{{ .Params.description | default (.Summary | plainify) | truncate 110 }}</p>
<span class="mt-3 inline-block text-sm font-semibold text-primary">{{ i18n "readMore" }} &rarr;</span>
</a>
{{- end -}}
</div>
</section>
{{- end -}}
{{- end -}}