From d56cdbad071712d5a609e9a659fbfc0dd5dcbaac Mon Sep 17 00:00:00 2001 From: fauno Date: Tue, 10 Jan 2017 15:12:37 -0300 Subject: [PATCH] show a warning when a category and a post share the same file name --- lib/jekyll-pandoc-multiple-formats/generator.rb | 7 +++++++ lib/jekyll-pandoc-multiple-formats/pandoc_file.rb | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-pandoc-multiple-formats/generator.rb b/lib/jekyll-pandoc-multiple-formats/generator.rb index 5a57b2c..a8174ea 100644 --- a/lib/jekyll-pandoc-multiple-formats/generator.rb +++ b/lib/jekyll-pandoc-multiple-formats/generator.rb @@ -50,6 +50,13 @@ def generate(site) @site.post_attr_hash('categories').each_pair do |title, posts| posts.sort! pandoc_file = PandocFile.new(@site, output, posts, title) + + if @site.keep_files.include? pandoc_file.relative_path + puts "#{pandoc_file.relative_path} is a category file AND a post file" + puts 'change the category name to fix this' + next + end + next unless pandoc_file.write @site.keep_files << pandoc_file.relative_path diff --git a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb index a145c20..14b698f 100644 --- a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb +++ b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb @@ -41,12 +41,12 @@ def initialize(site, format, posts, title = nil) raise ArgumentError.new "'title' argument is required for multipost file" unless title @title = title - @slug = Utils.slugify(title) else @posts = [posts] - @slug = posts.data['slug'] @title = posts.data['title'] unless title end + + @slug = Utils.slugify(title) end def path