Skip to content

Commit 2fc2e06

Browse files
committed
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.
1 parent 2f6c40b commit 2fc2e06

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Rakefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ task :post do
4747
title = ENV["title"] || "new-post"
4848
tags = ENV["tags"] || "[]"
4949
category = ENV["category"] || ""
50+
category = category.empty? ? "" : "\"#{category.gsub(/-/,' ')}\""
5051
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
5152
begin
5253
date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
@@ -65,7 +66,7 @@ task :post do
6566
post.puts "layout: post"
6667
post.puts "title: \"#{title.gsub(/-/,' ')}\""
6768
post.puts 'description: ""'
68-
post.puts "category: \"#{category.gsub(/-/,' ')}\""
69+
post.puts "category: #{category}"
6970
post.puts "tags: #{tags}"
7071
post.puts "---"
7172
post.puts "{% include JB/setup %}"

0 commit comments

Comments
 (0)