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:
parent
2f6c40b8b2
commit
2fc2e068e6
1 changed files with 2 additions and 1 deletions
3
Rakefile
3
Rakefile
|
@ -47,6 +47,7 @@ task :post do
|
||||||
title = ENV["title"] || "new-post"
|
title = ENV["title"] || "new-post"
|
||||||
tags = ENV["tags"] || "[]"
|
tags = ENV["tags"] || "[]"
|
||||||
category = ENV["category"] || ""
|
category = ENV["category"] || ""
|
||||||
|
category = category.empty? ? "" : "\"#{category.gsub(/-/,' ')}\""
|
||||||
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
||||||
begin
|
begin
|
||||||
date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
|
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 "layout: post"
|
||||||
post.puts "title: \"#{title.gsub(/-/,' ')}\""
|
post.puts "title: \"#{title.gsub(/-/,' ')}\""
|
||||||
post.puts 'description: ""'
|
post.puts 'description: ""'
|
||||||
post.puts "category: \"#{category.gsub(/-/,' ')}\""
|
post.puts "category: #{category}"
|
||||||
post.puts "tags: #{tags}"
|
post.puts "tags: #{tags}"
|
||||||
post.puts "---"
|
post.puts "---"
|
||||||
post.puts "{% include JB/setup %}"
|
post.puts "{% include JB/setup %}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue