From 67e09e0397a8a963d054616fb181e001e258138b Mon Sep 17 00:00:00 2001 From: "Patrick M. Niedzielski" <patrick@pniedzielski.net> Date: Fri, 27 Jan 2017 21:09:22 +0000 Subject: [PATCH] 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. --- lib/jekyll-pandoc-multiple-formats/pandoc_file.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb index 4828fd6..7afa130 100644 --- a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb +++ b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb @@ -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? -- GitLab