Skip to content

Commit 89530f6

Browse files
committedSep 23, 2013
Merge pull request #183 from Miguelos/patch-2
Update 'rake post' to support category on command line
2 parents fed94a2 + 56bc767 commit 89530f6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎Rakefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ module JB
4040
end #Path
4141
end #JB
4242

43-
# Usage: rake post title="A Title" [date="2012-02-09"] [tags=[tag1, tag2]]
43+
# Usage: rake post title="A Title" [date="2012-02-09"] [tags=[tag1,tag2]] [category="category"]
4444
desc "Begin a new post in #{CONFIG['posts']}"
4545
task :post do
4646
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
4747
title = ENV["title"] || "new-post"
4848
tags = ENV["tags"] || "[]"
49+
category = ENV["category"] || ""
4950
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
5051
begin
5152
date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
@@ -64,7 +65,7 @@ task :post do
6465
post.puts "layout: post"
6566
post.puts "title: \"#{title.gsub(/-/,' ')}\""
6667
post.puts 'description: ""'
67-
post.puts "category: "
68+
post.puts "category: \"#{category.gsub(/-/,' ')}\""
6869
post.puts "tags: #{tags}"
6970
post.puts "---"
7071
post.puts "{% include JB/setup %}"

0 commit comments

Comments
 (0)
Please sign in to comment.