Show related posts

This commit is contained in:
roneo.org 2022-09-23 07:15:35 +02:00
parent 3a0a4811cb
commit d6efc73123
5 changed files with 37 additions and 0 deletions

View File

@ -295,6 +295,18 @@
margin-top: 56px; margin-top: 56px;
} }
.post-footer h3 {
margin: 2em 0 1.2em;
}
.post-footer .related ul {
padding-inline-start: 20px;
}
.post-footer .related a:hover {
box-shadow: 0 1px;
}
.post-tags li { .post-tags li {
display: inline-block; display: inline-block;
margin-inline-end: 3px; margin-inline-end: 3px;

View File

@ -31,3 +31,6 @@
- id: code_copied - id: code_copied
translation: "copied!" translation: "copied!"
- id: related
translation: "See also"

View File

@ -31,3 +31,6 @@
- id: code_copied - id: code_copied
translation: "Copié !" translation: "Copié !"
- id: related
translation: "Voir aussi"

View File

@ -36,6 +36,12 @@
{{- end }} {{- end }}
<footer class="post-footer"> <footer class="post-footer">
{{/* Show related posts */}}
{{- if (.Param "ShowRelatedContent") }}
{{- partial "related.html" . }}
{{- end }}
{{- $tags := .Language.Params.Taxonomies.tag | default "tags" }} {{- $tags := .Language.Params.Taxonomies.tag | default "tags" }}
<ul class="post-tags"> <ul class="post-tags">
{{- range ($.GetTerms $tags) }} {{- range ($.GetTerms $tags) }}

View File

@ -0,0 +1,13 @@
{{ $related := first 5 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
{{ with $related }}
<div class="related">
<h3 class="see-also">{{- i18n "related" -}}</h3>
<ul>
{{ range . }}
<li>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
</div>
{{ end }}