Skip to content
Snippets Groups Projects
Unverified Commit 67e09e03 authored by Patrick M. Niedzielski's avatar Patrick M. Niedzielski
Browse files

Better distinguish between post and category

The constructor currently forgets the difference between a single post
and a category with only one post in it by wrapping any single post in
an array.  This causes the category to get the same generated URL as
the post itself, instead of using the configured bundle permalink
template.

To fix this, this patch teaches the constructor to remember whether it
received only a single post or an array containing a single post in
it.
parent 9636f53d
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ module Jekyll
include Convertible
attr_reader :format, :site, :config, :flags, :posts, :slug, :title, :url
attr_reader :format, :site, :config, :flags, :posts, :slug, :title, :url, :is_single_post
attr_reader :papersize, :sheetsize, :signature
def initialize(site, format, posts, title = nil)
......@@ -34,16 +34,17 @@ module Jekyll
@config = JekyllPandocMultipleFormats::Config.new(@site.config['pandoc']).config
@format = format
@flags = []
@is_single_post = not(posts.is_a? Array)
if posts.is_a? Array
if single_post?
@posts = [posts]
@title = title or posts.data['title']
else
@posts = posts
raise ArgumentError.new "'title' argument is required for multipost file" unless title
@title = title
else
@posts = [posts]
@title = title or posts.data['title']
end
@slug = Utils.slugify(@title)
......@@ -236,7 +237,7 @@ module Jekyll
end
def single_post?
@posts.count == 1
@is_single_post
end
def has_cover?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment