{{/* related.html (Enhanced UI + robust image fallback) */}} {{ if not .IsHome }} {{ $page := . }} {{ $max := .Params.related_max | default 4 }} {{ $tags := .Params.tags | default (slice) }} {{ $exclude := .Params.related_exclude | default (slice) }} {{ $manual := .Params.related_manual | default (slice) }} {{ $pages := slice }} {{/* Manuelle Auswahl? */}} {{ if gt (len $manual) 0 }} {{ range $manual }} {{ $p := site.GetPage . }} {{ if not $p }}{{ $p = site.GetPage (printf "/%s" (strings.TrimPrefix "/" .)) }}{{ end }} {{ if $p }}{{ $pages = $pages | append $p }}{{ end }} {{ end }} {{ $pages = first $max $pages }} {{ else }} {{/* Automatisch */}} {{ $recs := slice }} {{ range site.RegularPages }} {{ if or (eq .RelPermalink $page.RelPermalink) (in (slice "impressum" "datenschutz" "agb" "privacy") .Section) (in $exclude .RelPermalink) (in $exclude .File.TranslationBaseName) }} {{/* skip */}} {{ else }} {{ $candTags := .Params.tags | default (slice) }} {{ $tagScore := len (intersect $candTags $tags) }} {{/* Sektion-Priorität */}} {{ $secScore := 0 }} {{ if eq $page.Section "leistungen" }} {{ if or (eq .Section "fokusthemen") (in (slice "post" "posts" "blog" "blogs" "news") .Section) }}{{ $secScore = 1 }}{{ end }} {{ else if or (eq $page.Section "fokusthemen") (eq $page.Section "themen") }} {{ if or (eq .Section "leistungen") (in (slice "post" "posts" "blog" "blogs" "news") .Section) }}{{ $secScore = 1 }}{{ end }} {{ else if in (slice "post" "posts" "blog" "blogs" "news") $page.Section }} {{ if or (eq .Section "leistungen") (eq .Section "fokusthemen") (eq .Section "themen") }}{{ $secScore = 1 }}{{ end }} {{ end }} {{ $score := add (mul $tagScore 10) $secScore }} {{ if gt $score 0 }} {{ $recs = $recs | append (dict "p" . "s" $score "d" .Date) }} {{ end }} {{ end }} {{ end }} {{ $recs = sort $recs "s" "desc" "d" "desc" }} {{ range first $max $recs }} {{ $pages = $pages | append .p }} {{ end }} {{ end }} {{ if gt (len $pages) 0 }} {{ end }} {{ end }}