diff --git a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb index e7ff91f0cf3de9cbe6b09391aea84c9e85d6a636..956a649d07eae8e67d4b1a6663982c5ae42b8ede 100644 --- a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb +++ b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb @@ -36,22 +36,20 @@ module Jekyll @last_cat = nil @extra = extra - if posts.is_a? Array - @single_post = false + @single_post = not(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 - @slug = Utils.slugify(@title) - else - @single_post = true - @posts = [posts] - @title = title || posts.data['title'] - @slug = posts.data['slug'] end - self + @slug = Utils.slugify(@title) end def path @@ -75,6 +73,14 @@ module Jekyll path << @format end + # if permalink ends with trailing .html or trailing slash, path now ends with proper suffix + # for other cases (permalink with no trailing extension or slash), append format + # (ie /year/month/slug permalink --> /year/month/slug.pdf) + if not path.end_with? ".#{@format}" + path << '.' + path << @format + end + path end