Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for multiple authors #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions lib/blog_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,29 @@ def authors
end

def author_permalinks
data.authors ? data.authors.split(',').map{|author| Middleman::BlogAuthors::AuthorPages.permalink(author)} : []
if data.author
if data.author.kind_of?(Array)
authors = data.author
else
authors = [data.author]
end
else
authors = data.authors ? data.authors.split(',') : []
end
authors.map { |author| Middleman::BlogAuthors::AuthorPages.permalink(author) }
end

def author_names
data.authors ? data.authors.split(',').map{|author| author.strip} : []
if data.author
if data.author.kind_of?(Array)
data.author
else
[data.author]
end
else
data.authors ? data.authors.split(',').map{ |author| author.strip } : []
end
end
end
end
end
end
6 changes: 6 additions & 0 deletions lib/middleman-blog-authors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
class BlogAuthors < ::Middleman::Extension
option :author_path, "authors/:author.html", "Path to the individual author pages"
option :author_template, "author.html", "Template for the individual author pages"
option :per_page, 100, "Posts to show per page"
option :page_link, "page/{num}", "Path for pages"
expose_to_application blog_authors_options: :options
expose_to_application blog_authors_data: :blog_authors_data
attr_reader :blog_authors_options
Expand All @@ -26,6 +28,10 @@ def after_configuration
::Middleman::BlogAuthors::AuthorPages.new(@app, self),
false
)

require 'middleman-blog/paginator'
@paginator = ::Middleman::Blog::Paginator.new(@app, self)
@app.sitemap.register_resource_list_manipulator(:blog_authors_paginate, @paginator)
end

helpers do
Expand Down