Skip to content

Instantly share code, notes, and snippets.

View leigh-johnson's full-sized avatar
💜

Leigh Johnson leigh-johnson

💜
View GitHub Profile
@leigh-johnson
leigh-johnson / rakefile.rb
Last active August 29, 2015 14:05
Add HPSTR fields to rake new_post()
desc "Begin a new post in #{source_dir}/#{posts_dir}"
task :new_post, :title do |t, args|
if args.title
title = args.title
else
title = get_stdin("Enter a title for your post: ")
end
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
mkdir_p "#{source_dir}/#{posts_dir}"
filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"