From 5b39a943f720f74aeff0212d782078d9791b9ac4 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sun, 20 May 2012 16:36:03 -0500 Subject: [PATCH] Category directory can be set to root directory. Closes #331 #369 --- plugins/category_generator.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb index 33734e0..60ebd4e 100644 --- a/plugins/category_generator.rb +++ b/plugins/category_generator.rb @@ -106,9 +106,14 @@ module Jekyll # Loops through the list of category pages and processes each one. def write_category_indexes if self.layouts.key? 'category_index' - dir = self.config['category_dir'] || 'categories' + dir = self.config['category_dir'] self.categories.keys.each do |category| - self.write_category_index(File.join(dir, category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase), category) + category_slug = category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase + if dir.nil? or dir.empty? + self.write_category_index(category_slug, category) + else + self.write_category_index(File.join(dir, category_slug), category) + end end # Throw an exception if the layout couldn't be found. @@ -145,7 +150,11 @@ module Jekyll def category_links(categories) dir = @context.registers[:site].config['category_dir'] categories = categories.sort!.map do |item| - "#{item}" + if dir.nil? or dir.empty? + "#{item}" + else + "#{item}" + end end case categories.length