Skip to content
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

Redo author configuration #19

Closed
dencold opened this issue Aug 14, 2016 · 3 comments
Closed

Redo author configuration #19

dencold opened this issue Aug 14, 2016 · 3 comments

Comments

@dencold
Copy link
Owner

dencold commented Aug 14, 2016

Right now we configure author in two places:

  • the Site.Params section where there is a single author param. This serves two functions: it sets the "default" author for posts when no author is set in a piece of content and, when no details are set (see below) it also is what is used for the text of the author on posts.
  • the Site.Author map. This serves as a lookup for all available authors on the site and allows us to provide more detail about authors. We can set their location/bio/thumbnail, etc. here. We try to lookup this detail based on the author key that is set on any contnent, and if not set, we use whatever is set in Site.Params

This setup makes it very confusing for the templates to figure out what is going on with a configuration. Every time we want to show some author data, we have to go thru the following process:

  1. If an author key is set on the content, we try to index it in the Site.Author configuration.
  2. if it exists, we pull out the metadata required for the template
  3. if it doesn't exist we don't display anything
  4. if author key is not set on content, we check if Site.Params.Author is set. If so we use that as the key and repeat steps 1-2.
  5. if this author key can't be indexed in the Site.Author map, we then fallback to using the key value as the "name" parameter in the templates.

That's a lot for templates to have to manage.

I'd like to simplify this considerably by introducing a template function that can encapsulate all the logic of figuring out author metadata and just return it back to the caller. If anything is not set, it defaults to the empty string. This will remove all the safety checks we currently have to write in individual templates and move it to a place where it can be reused.

I'm not sure if Hugo allows themes to write custom functions, but I'm going to try.

@ryanwalls
Copy link
Contributor

Interesting. Yeah, the author handling needs a standard approach across themes. Don't know if one has been settled on. Perhaps raise an issue on the hugo repo itself as well?

@dencold
Copy link
Owner Author

dencold commented Aug 15, 2016

@ryanwalls yeah, Author config has really been a pain point. I've tried to be flexible on the theme and allow multiple-authors and additional metadata. Looks like there are some gears turning for some kind of official support in version 0.17 of hugo:
gohugoio/hugo#1850

I think you commented on this as well, so you are probably aware.

It turns out that you can't define custom template functions without forking Hugo, something I'm definitely not interested in pursuing as it will break downstream users (unless they also use my fork). So I'm going to hold off on this work until 0.17 when we have some official view on this from Hugo itself crosses fingers.

@dencold
Copy link
Owner Author

dencold commented Aug 29, 2016

Closing this issue. Author metadata is still awkward, but I think we have it in a good state until the official adoption of a standard in hugo:
gohugoio/hugo#1850

@dencold dencold closed this as completed Aug 29, 2016
dencold added a commit that referenced this issue Sep 29, 2016
- updated for the changes that were made in #19
- closes #25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants