Skip to content

Commit e26616e

Browse files
authored
Add authors taxonomy for blog posts (luizdepra#435)
* Add authors taxonomy and layout * Add my name to contributors file * Add authors to front matter post archetypes * Add author to i18n for en * Add authors taxonomy to exampleSite config * Add some author names to exampleSite for demo * Tested authors on pt-br and externally-linked post * Also ran make release again * Resources Deleted resources in exampleSite and added resources in root
1 parent 82ccf83 commit e26616e

File tree

11 files changed

+24
-3
lines changed

11 files changed

+24
-3
lines changed

CONTRIBUTORS.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@
8181
- [Rabin Adhikari](https://github.com/rabinadk1/)
8282
- [Hussaini Zulkifli](https://github.com/hussaini/)
8383
- [Ellison Leão](https://github.com/ellisonleao)
84-
- [Lucas de Oliveira](https://github.com/lucas-dOliveira)
84+
- [Lucas de Oliveira](https://github.com/lucas-dOliveira)
85+
- [earnest ma](https://github.com/earnestma)

archetypes/posts.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ draft = true
33
date = {{ .Date }}
44
title = ""
55
description = ""
6-
slug = ""
6+
slug = ""
7+
authors = []
78
tags = []
89
categories = []
910
externalLink = ""

exampleSite/config.toml

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ disqusShortname = "yourdiscussshortname"
8080
category = "categories"
8181
series = "series"
8282
tag = "tags"
83+
author = "authors"
8384

8485
[[params.social]]
8586
name = "Github"

exampleSite/content/posts/creating-a-new-theme.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
+++
22
date = "2014-09-28"
33
title = "Creating a New Theme"
4-
slug = "creating-a-new-theme"
4+
slug = "creating-a-new-theme"
55
tags = []
66
categories = []
77
series = ["Theme", "Hugo"]
8+
authors = ["John Doe"]
89
+++
910

1011
## Introduction

exampleSite/content/posts/dummy.pt-br.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title = "Dummy"
44
slug = "dummy"
55
tags = ["hugo", "i18n"]
66
categories = ["blog"]
7+
authors = ["Translation test"]
78
+++
89

910
Nada para ver aqui!

exampleSite/content/posts/external-post.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ categories = [
1212
]
1313
externalLink = "https://github.com/luizdepra/hugo-coder/wiki"
1414
series = ["Hugo"]
15+
authors = ["External link test"]
1516
+++

exampleSite/content/posts/goisforlovers.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ categories = [
1414
"golang",
1515
]
1616
series = ["Getting Started", "Hugo"]
17+
authors = ["Jane Smith"]
1718
+++
1819

1920
Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for

exampleSite/content/posts/theme-demo.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = "The post demonstrates features of the coder theme."
55
images = ["/images/N90.jpg"]
66
math = true
77
series = ["Theme", "Hugo"]
8+
authors = ["John Doe", "Jane Smith"]
89
+++
910

1011
## Style Demo

i18n/en.toml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ other = "tag"
77
[series]
88
other = "series"
99

10+
[author]
11+
other = "author"
12+
1013
[reading_time]
1114
one = "One-minute read"
1215
other = "{{ .Count }}-minute read"
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="authors">
2+
<i class="fa fa-user" aria-hidden="true"></i>
3+
{{- range $index, $el := . -}}
4+
{{- if gt $index 0 }}
5+
<span class="separator"></span>
6+
{{- end }}
7+
<a href="{{ ( printf "authors/%s/" ( . | urlize ) ) | relLangURL }}">{{ . }}</a>
8+
{{- end -}}
9+
</div>

layouts/posts/single.html

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ <h1 class="title">{{ .Title }}</h1>
2121
{{ i18n "reading_time" .ReadingTime }}
2222
</span>
2323
</div>
24+
{{ with .Page.Params.Authors }}{{ partial "taxonomy/authors.html" . }}{{ end }}
2425
{{ with .Page.Params.Categories }}{{ partial "taxonomy/categories.html" . }}{{ end }}
2526
{{ with .Page.Params.Tags }}{{ partial "taxonomy/tags.html" . }}{{ end }}
2627
</div>

0 commit comments

Comments
 (0)