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 ...@@ -26,7 +26,7 @@ module Jekyll
include Convertible 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 attr_reader :papersize, :sheetsize, :signature
def initialize(site, format, posts, title = nil) def initialize(site, format, posts, title = nil)
...@@ -34,16 +34,17 @@ module Jekyll ...@@ -34,16 +34,17 @@ module Jekyll
@config = JekyllPandocMultipleFormats::Config.new(@site.config['pandoc']).config @config = JekyllPandocMultipleFormats::Config.new(@site.config['pandoc']).config
@format = format @format = format
@flags = [] @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 @posts = posts
raise ArgumentError.new "'title' argument is required for multipost file" unless title raise ArgumentError.new "'title' argument is required for multipost file" unless title
@title = title @title = title
else
@posts = [posts]
@title = title or posts.data['title']
end end
@slug = Utils.slugify(@title) @slug = Utils.slugify(@title)
...@@ -236,7 +237,7 @@ module Jekyll ...@@ -236,7 +237,7 @@ module Jekyll
end end
def single_post? def single_post?
@posts.count == 1 @is_single_post
end end
def has_cover? def has_cover?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment