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.
This commit is contained in:
Matthew Parnell 2014-01-01 20:37:21 +00:00
parent 2f6c40b8b2
commit 2fc2e068e6

View file

@ -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 %}"