Files
tsuki/layouts/_partials/related-posts.html
T
tiennm99 4e243cca7d feat: related posts discovery with configurable algorithm
Add related posts sidebar component, configure related: block in Hugo config,
enable readers to discover similar content.
2026-05-09 09:32:33 +07:00

21 lines
736 B
HTML

{{- /*
Related posts for single pages. Uses Hugo's built-in `Related` keyword index.
Requires `related:` config in site hugo.yaml — see docs/config.md.
Silently no-op when no relations are found.
*/ -}}
{{- $count := site.Params.relatedPostsCount | default 3 -}}
{{- $related := slice -}}
{{- if gt $count 0 -}}
{{- $related = first $count (site.RegularPages.Related .) -}}
{{- end -}}
{{- with $related -}}
<aside class="related-posts" aria-labelledby="related-heading">
<h2 id="related-heading" class="related-heading">{{ i18n "relatedPosts" | default "Bài viết liên quan" }}</h2>
<ul class="related-list">
{{- range . }}
<li>{{ partial "post-card.html" . }}</li>
{{- end }}
</ul>
</aside>
{{- end -}}