Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Lookup author in site.data.authors #33

Merged
merged 2 commits into from
Feb 21, 2016
Merged

Lookup author in site.data.authors #33

merged 2 commits into from
Feb 21, 2016

Conversation

pathawks
Copy link
Member

Where will the plugin try to find a post author's Twitter username?

  1. site.data.authors[post.author].twitter
  2. site.data.authors[post.author].name
  3. post.author.twitter
  4. post.author.name
  5. post.author
  6. site.data.authors[site.author].twitter
  7. site.data.authors[site.author].name
  8. site.author.twitter
  9. site.author.name
  10. site.author

Ugh. I don't even begin to know how to document this. It is too bad that there isn't just one standard convention for all of this.
#31

@benbalter
Copy link
Collaborator

Looking through things, do we ever actually use seo_author_name? It looks like the only author information that's used is for the Twitter Card, which requires a twitter username, not a human-readable name. That should let us cut things in half.

We may be able to simplify things a bit further:

  1. Set seo_author to page.author or if that doesn't exist site.author
  2. If seo_author.twitter exists (it's an object), use that
  3. If site.authors[seo_author].twitter exists, use that
  4. seo_author

Does that account for every possible permutation?

@pathawks
Copy link
Member Author

Looking through things, do we ever actually use seo_author_name?

Not currently, but I would like to.

Honestly, it kind of feels like magic to assume that the author name will also just happen to match that user's Twitter username. Here is how I would really like to do things (in Ruby/pseudocode):

author = {}

if post.author.is_a? Hash
  author = post.author

elsif site.data.authors[post.author].is_a? Hash
  author = site.data.authors[post.author]

elsif post.author.is_a? String
  author = { 'name' : post.author }

elsif site.author.is_a? Hash
  author = site.data.authors[post.author]

elsif site.author.is_a? String
  author = { 'name' : site.author.to_s }

end

Then, we can use author.name or author.twitter or author.url or whatever anywhere we want.

As far as I know, Liquid has no way to check the type of an object or create hashes, so I'm not really sure of the best way to go about this...

@benbalter
Copy link
Collaborator

Yeah, looks like it's going to be a lot more sane in Ruby, and it's just string manipulation, so I don't think there's much security concern.

How about something like:

author = post.author || site.author # Default to post.author, fallback to site.author, both stings and objects
return author.twitter if author.twitter # The author is an object, use the Twitter property
return site.data.authors[author].twitter if site.data.authors[author].twitter # The author is a string, check for a matching key in the data 
author # The author is a string with no matching data, this is all we've got

That said, where would we use author.name within the plugin?

@pathawks pathawks mentioned this pull request Jan 29, 2016
@benbalter benbalter mentioned this pull request Feb 20, 2016
2 tasks
@benbalter benbalter merged commit 43fcf5b into master Feb 21, 2016
@pathawks pathawks deleted the pr/global-author branch February 21, 2016 23:15
@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants