Skip to content

Commit

Permalink
Merge pull request eduardoboucas#243 from pad92/patch-1
Browse files Browse the repository at this point in the history
[bugfix] related page
  • Loading branch information
halogenica authored Sep 21, 2019
2 parents 2dc99d8 + 0c9be32 commit f838d06
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@
{{ end }}

{{ if .Site.Params.showRelatedPosts }}
{{ $related := .Site.RegularPages.Related . | first 3 }}
{{ with $related }}
<h4 class="see-also">{{ i18n "seeAlso" }}</h4>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ range first 1 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
{{ $.Scratch.Set "has_related" true }}
{{ end }}
</ul>

{{ if $.Scratch.Get "has_related" }}
<h4 class="see-also">{{ i18n "seeAlso" }}</h4>
<ul>
{{ $num_to_show := .Site.Params.related_content_limit | default 5 }}
{{ range first $num_to_show (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>

{{ end }}
{{ end }}
</article>
Expand Down

0 comments on commit f838d06

Please sign in to comment.