Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lxndrblz/anatole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOsterberg <me@gummigroda.se>2022-03-27 14:17:44 +0300
committerGitHub <noreply@github.com>2022-03-27 14:17:44 +0300
commit6ad4d7aea163240dbb76ed405125c7e3eeda2605 (patch)
tree766e9e135e1a5477449cae7db047e9a06379b949 /layouts
parent4c83061aef11891f2a18f4cc1526bdeb58adda64 (diff)
feat: Add option to display related posts (#300)
* Added an option to display related posts Co-authored-by: Alexander Bilz <mail@alexbilz.com>
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/single.html5
-rw-r--r--layouts/partials/related.html11
2 files changed, 16 insertions, 0 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index e0954b2..887da1e 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -57,6 +57,11 @@
{{- end -}}
+ {{- if (eq .Site.Params.relatedPosts true) -}}
+ {{- partial "related.html" . -}}
+
+ {{- end -}}
+
{{- if (eq .Params.contact true) -}}
{{- partial "contact.html" . -}}
diff --git a/layouts/partials/related.html b/layouts/partials/related.html
new file mode 100644
index 0000000..fcb5bbd
--- /dev/null
+++ b/layouts/partials/related.html
@@ -0,0 +1,11 @@
+{{ $related := .Site.RegularPages.Related . | first .Site.Params.numberOfRelatedPosts }}
+{{ with $related }}
+ <h3>Related Posts</h3>
+ <ul>
+ {{ range . }}
+ <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+
+ {{ end }}
+ </ul>
+
+{{ end }}