New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add authors page #147
add authors page #147
Conversation
layouts/partials/head.html
Outdated
@@ -24,7 +24,7 @@ | |||
|
|||
<!-- author & description & keywords --> | |||
{{- if or .Params.author .Site.Author.name -}} | |||
<meta name="author" content="{{ if .Params.author }}{{ .Params.author | safeHTML }}{{ else }}{{ .Site.Author.name | safeHTML }}{{ end }}" /> | |||
<meta name="author" content="{{ (index .Site.Data.authors (.Params.author | default .Site.Author.name)).name.display | default .Params.author | default .Site.Author.name | safeHTML }}" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem here:
(index .Site.Data.authors (.Params.author | default .Site.Author.name)).name.display
If I don't have an "author data file" in the Site root , example /data/authors/example_author.toml
. Then, Hugo will output ERROR: error calling index: index of untyped nil.
Is there a better function to avoid this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I only tested when the author id is not available but didn't test the case when there is no authors file. Let's me investigate...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
Thanks for your great work!
|
Okay. The current implementation is to use the |
So I am trying to add a more prominent author information section into the post page. But I guess it's useful to implement #114 as a first step. Currently,
data/authors
only has a display name field, but I am planning to add more things to it in the future.However, there is something to discuss:
I personally feel that rather than keeping using the
author
field, it would be best to use anauthors
field, which takes a list of authors as its value. Because this would match the convention oftags
andcategories
, and it's also potentially possible that an article might have multiple authors. However, there is already a singularauthor
field in the past. So simply removing it might cause some compatibility issues. On the other hand, if we support both fields, it would be a little bit cumbersome. Not sure what is the best strategy here.