Quellcode durchsuchen

Add custom title / translation of authors (#756)

### Prerequisites

Put an `x` into the box(es) that apply:

- [X] This pull request fixes a bug.
- [X] This pull request adds a feature.
- [ ] This pull request introduces breaking change.

### Description

This PR is similar to #754 and #755, but updates the authors to utilize
Hugos taxonomy system, instead of the tags and categories.

This PR edits the posts/single layout to use .GetTerms "authors" to
fetch a richer model of the authors, and the taxonomy/authors partial to
use this model, instead of just urlizing the author name, so authors
with a custom title from the taxonomy system, renders correctly on a
post.

This also enables translation of the authors shown on a post, while
enabling switching languages on the author page without losing context.

To show this in action, I've added a translation of the "Hugo Authors"
author in the exampleSite into EN and PT-BR, as "Authors of Hugo" and
"Autores de Hugo", respectively, and switched both the EN and PT-BR page
for markdown-syntax to use the `authors` frontmatter (instead of
`author` like before) so the author is even rendered (most of the pages
in the exampleSite use `author` in the frontmatter, which does not show
up on the post - I didn't address this)


![image](https://user-images.githubusercontent.com/2725205/210679410-d1e184d8-5745-40ee-b3a2-3199d0206537.png)


![image](https://user-images.githubusercontent.com/2725205/210679300-6f3670fe-83a6-4fc5-a217-902690a5929c.png)

If you switch languages here on the author page, you'll see the
translated author name and corresponding posts, instead of dropping out
to the front page like before.


![image](https://user-images.githubusercontent.com/2725205/210679322-099d5f67-edcc-40d3-a428-4e2885e1ef51.png)

### Issues Resolved

If you wanted to use Hugo taxonomy system for the page authors, only the
author ids showed up on the post itself. This PR fixes that.

### Checklist

Put an `x` into the box(es) that apply:

#### General

- [X] Describe what changes are being made
- [X] Explain why and how the changes were necessary and implemented
respectively
- [ ] Reference issue with `#<ISSUE_NO>` if applicable

#### Resources

- [ ] If you have changed any SCSS code, run `make release` to
regenerate all CSS files

#### Contributors

- [ ] Add yourself to `CONTRIBUTORS.md` if you aren't on it already
Martin Hellspong vor 3 Jahren
Ursprung
Commit
aed63c6f96

+ 5 - 0
exampleSite/content/authors/hugo-authors/_index.md

@@ -0,0 +1,5 @@
++++ 
+draft = false
+date = 2023-01-05T01:15:29+01:00
+title = "Authors of Hugo"
++++

+ 6 - 0
exampleSite/content/authors/hugo-authors/_index.pt-br.md

@@ -0,0 +1,6 @@
++++ 
+draft = false
+date = 2023-01-05T01:15:52+01:00
+title = "Autores de Hugo"
+url = "autores/autores-de-hugo" 
++++

+ 1 - 1
exampleSite/content/posts/markdown-syntax.md

@@ -1,5 +1,5 @@
 +++
-author = "Hugo Authors"
+authors = ["Hugo Authors"]
 title = "Markdown Syntax Guide"
 date = "2019-03-11"
 description = "Sample article showcasing basic Markdown syntax and formatting for HTML elements."

+ 1 - 1
exampleSite/content/posts/markdown-syntax.pt-br.md

@@ -1,5 +1,5 @@
 +++
-author = "Hugo Authors"
+authors = ["Hugo Authors"]
 title = "Guia de Sintaxe Markdown"
 date = "2019-03-11"
 description = "Artigo de exemplo mostrando a sintaxe básica Markdown e a formatação de elementos HTML."

+ 1 - 1
layouts/partials/taxonomy/authors.html

@@ -4,6 +4,6 @@
     {{- if gt $index 0 }}
       <span class="separator">•</span>
     {{- end }}
-    <a href="{{ ( printf "authors/%s/" ( . | urlize ) ) | relLangURL }}">{{ . }}</a>
+    <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
   {{- end -}}
 </div>

+ 1 - 1
layouts/posts/single.html

@@ -25,7 +25,7 @@
               {{ i18n "reading_time" .ReadingTime }}
             </span>
           </div>
-          {{ with .Page.Params.Authors }}{{ partial "taxonomy/authors.html" . }}{{ end }}
+          {{ with .GetTerms "authors" }}{{ partial "taxonomy/authors.html" . }}{{ end }}
           {{ with .Page.Params.Categories }}{{ partial "taxonomy/categories.html" . }}{{ end }}
           {{ with .GetTerms "tags" }}{{ partial "taxonomy/tags.html" . }}{{ end }}
         </div>