Skip to content

Commit e68ba50

Browse files
committed
Adds rake task for creating a new post
1 parent af9369f commit e68ba50

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Rakefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'date'
2+
3+
desc "Create blog post with :name"
4+
task :new_post, [:name] do |t, args|
5+
post_name = [Date.today.strftime("%Y-%m-%d"), "-", args[:name].downcase.gsub(" ","-"),".md"].join
6+
puts "Creating blog post with name: \n _posts/#{post_name}"
7+
File.open("_posts/#{post_name}", 'w') do |f|
8+
f.puts "---"
9+
f.puts "layout: post"
10+
f.puts "title: #{args[:name]}"
11+
f.puts "categories:"
12+
f.puts "- blog"
13+
f.puts "---"
14+
f.puts ""
15+
end
16+
17+
## Open the new post within vim
18+
exec "vim _posts/#{post_name}"
19+
end

0 commit comments

Comments
 (0)