mirror of https://github.com/luizdepra/hugo-coder.git

Martin Hellspong
05.21.2023 aed63c6f967c43c1337fb2df850f37f715b7ed7f
refs
author Martin Hellspong <martin.hellspong@factor10.com>
Thursday, January 5, 2023 13:21 +0100
committer GitHub <noreply@github.com>
Thursday, January 5, 2023 13:21 +0100
commitaed63c6f967c43c1337fb2df850f37f715b7ed7f
tree c55de965d0a9495a179152f9eadd2867747623e0 tree | zip | gz
parent 3bddd3fd942a264cdc07ab20b819d8a3a4bed0e4 view | diff
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
2 files added
4 files modified
19 ■■■■ changed files
exampleSite/content/authors/hugo-authors/_index.md 5 ●●●●● diff | view | raw | blame | history
exampleSite/content/authors/hugo-authors/_index.pt-br.md 6 ●●●●● diff | view | raw | blame | history
exampleSite/content/posts/markdown-syntax.md 2 ●●● diff | view | raw | blame | history
exampleSite/content/posts/markdown-syntax.pt-br.md 2 ●●● diff | view | raw | blame | history
layouts/partials/taxonomy/authors.html 2 ●●● diff | view | raw | blame | history
layouts/posts/single.html 2 ●●● diff | view | raw | blame | history