Explorar el Código

posts: Show related content

* Requires Hugo 0.27+
* Refer to https://gohugo.io/content-management/related/
George Cushen hace 8 años
padre
commit
ab24e5646c
Se han modificado 3 ficheros con 18 adiciones y 1 borrados
  1. 5 0
      i18n/en.yaml
  2. 12 0
      layouts/_default/single.html
  3. 1 1
      theme.toml

+ 5 - 0
i18n/en.yaml

@@ -6,6 +6,11 @@
 - id: table_of_contents
   translation: Table of Contents
 
+# General
+
+- id: related
+  translation: Related
+
 # Buttons
 
 - id: btn_details

+ 12 - 0
layouts/_default/single.html

@@ -15,6 +15,18 @@
 
 </article>
 
+{{ $related := .Site.RegularPages.Related . | first 5 }}
+{{ with $related }}
+<div class="article-container">
+  <h3>{{ i18n "related" }}</h3>
+  <ul>
+    {{ range . }}
+    <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+    {{ end }}
+  </ul>
+</div>
+{{ end }}
+
 <div class="container">
   {{ partial "section_pager.html" . }}
 </div>

+ 1 - 1
theme.toml

@@ -3,7 +3,7 @@ license = "MIT"
 licenselink = "https://github.com/gcushen/hugo-academic/blob/master/LICENSE.md"
 description = "Easily create beautifully simple academic or personal sites"
 homepage = "https://github.com/gcushen/hugo-academic"
-min_version = 0.24
+min_version = 0.27
 tags = ["academic",
         "portfolio",
         "responsive",