From da6e48473c70f5c58ff630911b19d35ff225b654 Mon Sep 17 00:00:00 2001 From: Luis Felipe Sanchez Date: Thu, 14 Dec 2017 09:01:43 -0500 Subject: [PATCH 1/2] Make AutGenerator get posts by author. --- _plugins/jekyll-autgenerator.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/_plugins/jekyll-autgenerator.rb b/_plugins/jekyll-autgenerator.rb index 9a1b80500..3d8674b31 100755 --- a/_plugins/jekyll-autgenerator.rb +++ b/_plugins/jekyll-autgenerator.rb @@ -5,8 +5,9 @@ class AuthorsGenerator < Generator safe true def generate(site) - site.categories.each do |author| - build_subpages(site, "author", author) + site.data['authors'].each do |author, data| + posts = [author, posts_by_author(author)] + build_subpages(site, 'author', posts) end end @@ -36,6 +37,12 @@ def paginate(site, type, posts) end end + + private + + def posts_by_author(author) + site.posts.docs.select { |post| post.data['author'] == author } + end end class GroupSubPageAuthor < Page From a125898ee8725ad0fffc142e60d1ba2ef6b85d78 Mon Sep 17 00:00:00 2001 From: Luis Felipe Sanchez Date: Thu, 14 Dec 2017 09:45:55 -0500 Subject: [PATCH 2/2] Pass the site variable to posts_by_author. --- _plugins/jekyll-autgenerator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_plugins/jekyll-autgenerator.rb b/_plugins/jekyll-autgenerator.rb index 3d8674b31..108a129d8 100755 --- a/_plugins/jekyll-autgenerator.rb +++ b/_plugins/jekyll-autgenerator.rb @@ -6,7 +6,7 @@ class AuthorsGenerator < Generator def generate(site) site.data['authors'].each do |author, data| - posts = [author, posts_by_author(author)] + posts = [author, posts_by_author(site, author)] build_subpages(site, 'author', posts) end end @@ -40,7 +40,7 @@ def paginate(site, type, posts) private - def posts_by_author(author) + def posts_by_author(site, author) site.posts.docs.select { |post| post.data['author'] == author } end end