From 2fc2e068e6202e3a55e65807cf7d0ca7e851a765 Mon Sep 17 00:00:00 2001 From: Matthew Parnell Date: Wed, 1 Jan 2014 20:37:21 +0000 Subject: [PATCH] Remove empty quotes when category is empty. When category = "" Should print "category: " to file, current behaviour prints "category: \"\"". Latter creates an actual category, with a blank title. All posts created since this update, without a category explicitly written in `rake` command, or post directly edited, will belong to this category. --- Rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 176c94b..f8f470b 100644 --- a/Rakefile +++ b/Rakefile @@ -47,6 +47,7 @@ task :post do title = ENV["title"] || "new-post" tags = ENV["tags"] || "[]" category = ENV["category"] || "" + category = category.empty? ? "" : "\"#{category.gsub(/-/,' ')}\"" slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') begin date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d') @@ -65,7 +66,7 @@ task :post do post.puts "layout: post" post.puts "title: \"#{title.gsub(/-/,' ')}\"" post.puts 'description: ""' - post.puts "category: \"#{category.gsub(/-/,' ')}\"" + post.puts "category: #{category}" post.puts "tags: #{tags}" post.puts "---" post.puts "{% include JB/setup %}"