diff --git a/_includes/blog_post.html b/_includes/blog_post.html index f960292a..a6978d12 100644 --- a/_includes/blog_post.html +++ b/_includes/blog_post.html @@ -1,5 +1,4 @@ {% assign page = include.page %} -{% assign author = site.data.authors[page.author] %}

{% if include.isPermalink %} @@ -12,10 +11,10 @@

{{ page.date | date: "%B %e, %Y" }} by - {% if author.url %} - {{ author.name }} + {% if page.author.url %} + {{ page.author.name }} {% else %} - {{ author.name }} + {{ page.author.name }} {% endif %}

diff --git a/_plugins/authors.rb b/_plugins/authors.rb new file mode 100644 index 00000000..9630e1f0 --- /dev/null +++ b/_plugins/authors.rb @@ -0,0 +1,14 @@ +# This transforms the data associated with each post, specifically the author. +# We store our author information in a yaml file and specify the keys in The +# post front matter. Instead of looking up the complete data each time we need +# it, we'll just look it up here and assign. This plays nicely with tools like +# jekyll-feed which expect post.author to be in a specific format. +module Authors + class Generator < Jekyll::Generator + def generate(site) + site.posts.each do |post| + post.data['author'] = site.data['authors'][post['author']] + end + end + end +end diff --git a/blog/all.html b/blog/all.html index f8efa0a9..ecb7cd71 100644 --- a/blog/all.html +++ b/blog/all.html @@ -9,8 +9,7 @@ id: all-posts

All Posts

{% for page in site.posts %} - {% assign author = site.data.authors[page.author] %} -

{{ page.title }} on {{ page.date | date: "%B %e, %Y" }} by {{ author.name }}

+

{{ page.title }} on {{ page.date | date: "%B %e, %Y" }} by {{ page.author.name }}

{% endfor %}