Skip to content

Instantly share code, notes, and snippets.

@nazt
Forked from MattHall/Rakefile
Created December 9, 2012 20:46
Show Gist options
  • Save nazt/4246906 to your computer and use it in GitHub Desktop.
Save nazt/4246906 to your computer and use it in GitHub Desktop.
Rake task for creating new posts in Jekyll
require 'rubygems'
require 'optparse'
require 'yaml'
desc 'create a new draft post'
task :np do
OptionParser.new.parse!
ARGV.shift
title = ARGV.join(' ')
path = "_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
if File.exist?(path)
puts "[WARN] File exists - skipping create"
else
File.open(path, "w") do |file|
file.puts YAML.dump({'layout' => 'post', 'published' => false, 'title' => title})
file.puts "---"
end
end
`osascript ./applescript/open-byword.scpt #{Dir.pwd}/#{path}`
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment