Skip to content

Commit

Permalink
Merge pull request jekyllt#16 from sanchez2210/autgenerator-by-author
Browse files Browse the repository at this point in the history
Make AutGenerator get posts by author.
  • Loading branch information
biomadeira authored Dec 14, 2017
2 parents ec510fa + a125898 commit e4775cb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions _plugins/jekyll-autgenerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(site, author)]
build_subpages(site, 'author', posts)
end
end

Expand Down Expand Up @@ -36,6 +37,12 @@ def paginate(site, type, posts)

end
end

private

def posts_by_author(site, author)
site.posts.docs.select { |post| post.data['author'] == author }
end
end

class GroupSubPageAuthor < Page
Expand Down

0 comments on commit e4775cb

Please sign in to comment.