hide related section if no related articles

This commit is contained in:
Gabriele Musco 2021-04-15 10:24:50 +02:00
parent 9f75eb3378
commit 4fa759d2c8
No known key found for this signature in database
GPG Key ID: 8539FD3454380B83
1 changed files with 13 additions and 11 deletions

View File

@ -6,16 +6,18 @@
) "Params.tags" "intersect" .Params.tags
) "Permalink" "ne" .Permalink
}}
{{ if site.Params.randomRelated | default false }}
{{ $postsList = shuffle $postsList }}
{{ end }}
<div class="relatedArticlesContainer">
<hr />
<h2>More posts like this</h2>
<div class="postlist {{ if .Site.Params.gridView }}gridView{{ end }}">
{{ range first (.Site.Params.relatedArticlesNum | default 2) $postsList }}
{{- partial "article_card.html" . -}}
{{ end }}
{{ if $postsList }}
{{ if site.Params.randomRelated | default false }}
{{ $postsList = shuffle $postsList }}
{{ end }}
<div class="relatedArticlesContainer">
<hr />
<h2>More posts like this</h2>
<div class="postlist {{ if .Site.Params.gridView }}gridView{{ end }}">
{{ range first (.Site.Params.relatedArticlesNum | default 2) $postsList }}
{{- partial "article_card.html" . -}}
{{ end }}
</div>
</div>
</div>
{{ end }}
{{ end }}