From e26616e170cb5db79b24c6e27a1f873a064429b5 Mon Sep 17 00:00:00 2001
From: earnest <earnestma@outlook.at>
Date: Fri, 16 Oct 2020 18:32:37 +0000
Subject: [PATCH] Add authors taxonomy for blog posts (#435)

---
 exampleSite/config.toml                           |    1 +
 exampleSite/content/posts/external-post.md        |    1 +
 layouts/posts/single.html                         |    1 +
 archetypes/posts.md                               |    3 ++-
 i18n/en.toml                                      |    3 +++
 exampleSite/content/posts/creating-a-new-theme.md |    3 ++-
 layouts/partials/taxonomy/authors.html            |    9 +++++++++
 exampleSite/content/posts/dummy.pt-br.md          |    1 +
 exampleSite/content/posts/theme-demo.md           |    1 +
 exampleSite/content/posts/goisforlovers.md        |    1 +
 CONTRIBUTORS.md                                   |    3 ++-
 11 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 33d82a5..43d1607 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -81,4 +81,5 @@
 - [Rabin Adhikari](https://github.com/rabinadk1/)
 - [Hussaini Zulkifli](https://github.com/hussaini/)
 - [Ellison Leão](https://github.com/ellisonleao)
-- [Lucas de Oliveira](https://github.com/lucas-dOliveira)
\ No newline at end of file
+- [Lucas de Oliveira](https://github.com/lucas-dOliveira)
+- [earnest ma](https://github.com/earnestma)
diff --git a/archetypes/posts.md b/archetypes/posts.md
index afdb40e..76242f8 100644
--- a/archetypes/posts.md
+++ b/archetypes/posts.md
@@ -3,7 +3,8 @@
 date = {{ .Date }}
 title = ""
 description = ""
-slug = "" 
+slug = ""
+authors = []
 tags = []
 categories = []
 externalLink = ""
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 6f8eae8..5aa32b2 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -80,6 +80,7 @@
   category = "categories"
   series = "series"
   tag = "tags"
+  author = "authors"
 
 [[params.social]]
     name = "Github"
diff --git a/exampleSite/content/posts/creating-a-new-theme.md b/exampleSite/content/posts/creating-a-new-theme.md
index dbf15d5..0db1741 100644
--- a/exampleSite/content/posts/creating-a-new-theme.md
+++ b/exampleSite/content/posts/creating-a-new-theme.md
@@ -1,10 +1,11 @@
 +++ 
 date = "2014-09-28"
 title = "Creating a New Theme"
-slug = "creating-a-new-theme" 
+slug = "creating-a-new-theme"
 tags = []
 categories = []
 series = ["Theme", "Hugo"]
+authors = ["John Doe"]
 +++
 
 ## Introduction
diff --git a/exampleSite/content/posts/dummy.pt-br.md b/exampleSite/content/posts/dummy.pt-br.md
index 961957b..5d29277 100644
--- a/exampleSite/content/posts/dummy.pt-br.md
+++ b/exampleSite/content/posts/dummy.pt-br.md
@@ -4,6 +4,7 @@
 slug = "dummy" 
 tags = ["hugo", "i18n"]
 categories = ["blog"]
+authors = ["Translation test"]
 +++
 
 Nada para ver aqui!
\ No newline at end of file
diff --git a/exampleSite/content/posts/external-post.md b/exampleSite/content/posts/external-post.md
index 695d4bf..46abc59 100644
--- a/exampleSite/content/posts/external-post.md
+++ b/exampleSite/content/posts/external-post.md
@@ -12,4 +12,5 @@
 ]
 externalLink = "https://github.com/luizdepra/hugo-coder/wiki"
 series = ["Hugo"]
+authors = ["External link test"]
 +++
diff --git a/exampleSite/content/posts/goisforlovers.md b/exampleSite/content/posts/goisforlovers.md
index c850d5c..4e6e7a4 100644
--- a/exampleSite/content/posts/goisforlovers.md
+++ b/exampleSite/content/posts/goisforlovers.md
@@ -14,6 +14,7 @@
     "golang",
 ]
 series = ["Getting Started", "Hugo"]
+authors = ["Jane Smith"]
 +++
 
 Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for
diff --git a/exampleSite/content/posts/theme-demo.md b/exampleSite/content/posts/theme-demo.md
index 78241b4..be8a989 100644
--- a/exampleSite/content/posts/theme-demo.md
+++ b/exampleSite/content/posts/theme-demo.md
@@ -5,6 +5,7 @@
 images = ["/images/N90.jpg"]
 math = true
 series = ["Theme", "Hugo"]
+authors = ["John Doe", "Jane Smith"]
 +++
 
 ## Style Demo
diff --git a/i18n/en.toml b/i18n/en.toml
index 8dbe838..9715b85 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -7,6 +7,9 @@
 [series]
 other = "series"
 
+[author]
+other = "author"
+
 [reading_time]
 one = "One-minute read"
 other = "{{ .Count }}-minute read"
diff --git a/layouts/partials/taxonomy/authors.html b/layouts/partials/taxonomy/authors.html
new file mode 100644
index 0000000..366d8d8
--- /dev/null
+++ b/layouts/partials/taxonomy/authors.html
@@ -0,0 +1,9 @@
+<div class="authors">
+    <i class="fa fa-user" aria-hidden="true"></i>
+    {{- range $index, $el := . -}}
+      {{- if gt $index 0 }}
+        <span class="separator">•</span>
+      {{- end }}
+      <a href="{{ ( printf "authors/%s/" ( . | urlize ) ) | relLangURL }}">{{ . }}</a>
+    {{- end -}}
+  </div>
\ No newline at end of file
diff --git a/layouts/posts/single.html b/layouts/posts/single.html
index 1b5d642..0f38237 100644
--- a/layouts/posts/single.html
+++ b/layouts/posts/single.html
@@ -21,6 +21,7 @@
               {{ i18n "reading_time" .ReadingTime }}
             </span>
           </div>
+          {{ with .Page.Params.Authors }}{{ partial "taxonomy/authors.html" . }}{{ end }}
           {{ with .Page.Params.Categories }}{{ partial "taxonomy/categories.html" . }}{{ end }}
           {{ with .Page.Params.Tags }}{{ partial "taxonomy/tags.html" . }}{{ end }}
         </div>

--
Gitblit v1.10.0