1
Fork 0

Add related content to pages

Couldn't get it showing pages in the past, because Hugos docs on what the default are appear to be incorrect
This commit is contained in:
Jake Howard 2020-07-24 22:44:08 +01:00
parent 4f27ea96e7
commit 7dd9793f03
Signed by: jake
GPG key ID: 57AFB45680EDD477
6 changed files with 35 additions and 1 deletions

View file

@ -40,3 +40,13 @@ theme:
- utils - utils
assetDir: static/build/ assetDir: static/build/
related:
threshold: 80
includeNewer: false
toLower: false
indices:
- name: keywords
weight: 100
- name: date
weight: 10

View file

@ -24,5 +24,6 @@
</h4> </h4>
</div> </div>
{{ partial "share.html" . }} {{ partial "share.html" . }}
{{ partial "related-content.html" . }}
</div> </div>
{{ end }} {{ end }}

View file

@ -4,5 +4,6 @@
{{ partial "content.html" . }} {{ partial "content.html" . }}
</div> </div>
{{ partial "share.html" . }} {{ partial "share.html" . }}
{{ partial "related-content.html" . }}
</div> </div>
{{ end }} {{ end }}

View file

@ -53,5 +53,6 @@
</div> </div>
</div> </div>
{{ partial "share.html" . }} {{ partial "share.html" . }}
{{ partial "related-content.html" . }}
</div> </div>
{{ end }} {{ end }}

View file

@ -0,0 +1,21 @@
{{ if .Section }}
{{ $pages := where .Site.RegularPages "Section" .Section }}
{{ $related := ($pages.Related .) | first 3 }}
{{ if $related }}
{{ $col := printf "col-md-%d" (div 12 (len $related)) }}
<div class="container mt-5 text-center">
<h3 class="m-0">Related content</h3>
<div class="row">
{{ range $related }}
<div class="{{ $col }} mt-4">
<h5><a href="{{ .RelPermalink }}">{{ .Title }}</a></h5>
{{ partial "content-details.html" . }}
</div>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}

View file

@ -1,5 +1,5 @@
{{ if .Section }} {{ if .Section }}
<div class="container mt-3 text-center"> <div class="container mt-4 text-center">
<small>Share this page</small> <small>Share this page</small>
<h3> <h3>
<a href="https://twitter.com/intent/tweet?text={{ .Permalink }}"><i class="mx-1 fab fa-twitter" aria-hidden="true"></i></a> <a href="https://twitter.com/intent/tweet?text={{ .Permalink }}"><i class="mx-1 fab fa-twitter" aria-hidden="true"></i></a>