jekyll / jekyll-feed

:memo: A Jekyll plugin to generate an Atom (RSS-like) feed of your Jekyll posts
MIT License
846 stars 203 forks source link

Find author by reference #62

Closed silvenon closed 8 years ago

silvenon commented 9 years ago

On my blog there are two authors. Their properties are defined in the _config.yml:

authors:
  foo:
    name: "Foo"
    email: "foo@domain.com"
    uri: "http://foo.com"
  bar:
    name: "Bar"
    email: "bar@domain.com"
    uri: "http://bar.com"

In the post's YAML frontmatter I put:

title: My Post
author: foo

Then later I extract the actual author with site.authors[post.author]. I do this so I don't have to write all those details in each post.

Is there a way to make something like this work with jekyll-feed?

benbalter commented 9 years ago

Is there a way to make something like this work with jekyll-feed?

This is not something that's currently supported. Author information must either be universal in the configuration or specific to the post.

silvenon commented 9 years ago

Ok. It's not that big of a deal anyway.

parkr commented 9 years ago

I certainly wouldn't mind supporting something like this if we decide we think having an authors datafile is the "best practice".

silvenon commented 9 years ago

Ok, I'll reopen for a possible discussion. Close if you decide against it :+1:

sondr3 commented 9 years ago

Please do, it would be great to have some official best practices regarding naming stuff in your _config.yml file and so on, because right now it's a bit of a mess :smiley:

silvenon commented 9 years ago

This seems reasonable…

config.yml:

authors:
  default:
    name: "Default"
    email: "default@domain.com"
    url: "http://default.com"
  foo:
    name: "Foo"
    email: "foo@domain.com"
    uri: "http://foo.com"
  bar:
    name: "Bar"
    email: "bar@domain.com"
    uri: "http://bar.com"

_posts/my-post.md:

title: My Post
# author defaults to site.authors.default

_posts/my-other-post.md

title: My Other Post
author: foo
# maps to site.authors.foo

But I guess in order for this to make sense, it needs to be a Jekyll feature?

parkr commented 9 years ago

Check out https://github.com/jekyll/jekyll/issues/3983. This may solve everything for you.

silvenon commented 9 years ago

@parkr yes, that's perfect :heart:

Because this is really a jekyll shortcoming, not jeykll-feed's, you can close if you want.

eirc commented 9 years ago

As a workaround for author display names you can you the author's display name as the key in the authors yaml hash. This still won't be able to provide you with the author's email & uri for the feed since the plugin will just get the name string, it will provide you with a friendly name though:

_config.yml:

authors:
  Mr Poster:
    attribute1: value1
    attribute2: value2

_posts/my-post.md:

title: My Post
author: Mr Poster
pathawks commented 8 years ago

If author data is going to be stored separately from the post, it seems that the way to do it would be with a data file, rather than cluttering up the _config.yml