Bläddra i källkod

Add see also section to posts footer (#152)

* Fix series list page title

* Add see also section to posts footer
Joseph Ting 6 år sedan
förälder
incheckning
27e83b1e5a

+ 6 - 0
assets/scss/_content.scss

@@ -19,6 +19,12 @@
     }
     footer {
       margin-top: 4.0rem;
+      .see-also {
+        margin: 3.2rem 0;
+        h3 {
+          margin: 3.2rem 0;
+        }
+      }
     }
   }
   .post {

+ 3 - 0
exampleSite/config.toml

@@ -36,6 +36,9 @@ disqusShortname = "yourdiscussshortname"
     # Use inverted colors
     inverted = false
 
+    # Series see also post count
+    maxSeeAlsoItems = 5
+
     # Custom CSS
     custom_css = []
 

+ 1 - 0
exampleSite/content/posts/creating-a-new-theme.md

@@ -4,6 +4,7 @@ title = "Creating a New Theme"
 slug = "creating-a-new-theme" 
 tags = []
 categories = []
+series = ["Theme", "Hugo"]
 +++
 
 ## Introduction

+ 1 - 0
exampleSite/content/posts/external-post.md

@@ -11,4 +11,5 @@ categories = [
     "Development",
 ]
 externalLink = "https://github.com/luizdepra/hugo-coder/wiki"
+series = ["Hugo"]
 +++

+ 1 - 1
exampleSite/content/posts/goisforlovers.md

@@ -13,7 +13,7 @@ categories = [
     "Development",
     "golang",
 ]
-series = ["Getting Started"]
+series = ["Getting Started", "Hugo"]
 +++
 
 Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for

+ 1 - 1
exampleSite/content/posts/hugoisforlovers.md

@@ -11,7 +11,7 @@ categories = [
     "Development",
     "golang",
 ]
-series = ["Getting Started"]
+series = ["Getting Started", "Hugo"]
 +++
 
 ## Step 1. Install Hugo

+ 1 - 1
exampleSite/content/posts/migrate-from-jekyll.md

@@ -2,7 +2,7 @@
 date = "2014-03-10"
 title = "Migrate to Hugo from Jekyll"
 description = "The post explains how to migrate from from Jekyll to Hugo."
-series = ["Getting Started"]
+series = ["Getting Started", "Hugo"]
 +++
 
 Table of Contents

+ 1 - 1
exampleSite/content/posts/theme-demo.md

@@ -4,7 +4,7 @@ title = "Theme Demo"
 description = "The post demonstrates features of the coder theme."
 images = ["/images/N90.jpg"]
 math = "true"
-
+series = ["Theme", "Hugo"]
 +++
 
 ## Style Demo

+ 3 - 0
i18n/en.toml

@@ -4,6 +4,9 @@ other = "category"
 [tag]
 other = "tag"
 
+[series]
+other = "series"
+
 [reading_time]
 one = "One minute read"
 other = "{{ .Count }} minutes read"

+ 3 - 0
i18n/pt-br.toml

@@ -4,6 +4,9 @@ other = "categoria"
 [tag]
 other = "tag"
 
+[series]
+other = "séries"
+
 [reading_time]
 one = "Um minuto de leitura"
 other = "{{ .Count }} minutos de leitura"

+ 24 - 0
layouts/partials/posts/series.html

@@ -0,0 +1,24 @@
+{{ $currentPageUrl := .URL }}
+{{ if .Params.series }}
+<section class="see-also">
+  {{ range .Params.series }}
+    <h3>See also in {{ . }}</h3>
+    {{ $name := . | urlize }}
+    {{ $series := index $.Site.Taxonomies.series $name }}
+    {{ if gt (len $series.Pages) 0 }}
+      <nav>
+        <ul>
+        {{ $maxItems := $.Site.Params.maxSeeAlsoItems | default 5 }}
+        {{ range first (add $maxItems 1) $series.Pages }}
+          {{ if ne .URL $currentPageUrl }}
+            <li>
+              <a href="{{ .Params.ExternalLink | default .URL }}">{{ .Title }}</a>
+            </li>
+          {{ end }}
+        {{ end }}
+        </ul>
+      </nav>
+    {{ end }}
+  {{ end }}
+</section>
+{{ end }}

+ 1 - 0
layouts/posts/single.html

@@ -31,6 +31,7 @@
       </div>
 
       <footer>
+        {{ partial "posts/series" . }}
         {{ partial "posts/disqus" . }}
       </footer>
     </article>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
resources/_gen/assets/scss/scss/coder.scss_5e1eb8e37c42cdfb6215b61e44dcfa5f.content


+ 1 - 1
resources/_gen/assets/scss/scss/coder.scss_5e1eb8e37c42cdfb6215b61e44dcfa5f.json

@@ -1 +1 @@
-{"Target":"css/coder.min.8881182b3ec36ffd9c735306f7e16ce9b1129ebc650e069e7c4114827e9d9b23.css","MediaType":"text/css","Data":{"Integrity":"sha256-iIEYKz7Db/2cc1MG9+Fs6bESnrxlDgaefEEUgn6dmyM="}}
+{"Target":"css/coder.min.28d751104f30c16da1aa1bb04015cbe662cacfe0d1b01af4f2240ad58580069c.css","MediaType":"text/css","Data":{"Integrity":"sha256-KNdREE8wwW2hqhuwQBXL5mLKz+DRsBr08iQK1YWABpw="}}

Vissa filer visades inte eftersom för många filer har ändrats