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:
parent
4f27ea96e7
commit
7dd9793f03
6 changed files with 35 additions and 1 deletions
10
config.yml
10
config.yml
|
@ -40,3 +40,13 @@ theme:
|
|||
- utils
|
||||
|
||||
assetDir: static/build/
|
||||
|
||||
related:
|
||||
threshold: 80
|
||||
includeNewer: false
|
||||
toLower: false
|
||||
indices:
|
||||
- name: keywords
|
||||
weight: 100
|
||||
- name: date
|
||||
weight: 10
|
||||
|
|
|
@ -24,5 +24,6 @@
|
|||
</h4>
|
||||
</div>
|
||||
{{ partial "share.html" . }}
|
||||
{{ partial "related-content.html" . }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
{{ partial "content.html" . }}
|
||||
</div>
|
||||
{{ partial "share.html" . }}
|
||||
{{ partial "related-content.html" . }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
|
|
@ -53,5 +53,6 @@
|
|||
</div>
|
||||
</div>
|
||||
{{ partial "share.html" . }}
|
||||
{{ partial "related-content.html" . }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
|
21
layouts/partials/related-content.html
Normal file
21
layouts/partials/related-content.html
Normal 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 }}
|
|
@ -1,5 +1,5 @@
|
|||
{{ if .Section }}
|
||||
<div class="container mt-3 text-center">
|
||||
<div class="container mt-4 text-center">
|
||||
<small>Share this page</small>
|
||||
<h3>
|
||||
<a href="https://twitter.com/intent/tweet?text={{ .Permalink }}"><i class="mx-1 fab fa-twitter" aria-hidden="true"></i></a>
|
||||
|
|
Loading…
Reference in a new issue