Skip to content

Instantly share code, notes, and snippets.

@devn
Created July 2, 2010 13:36
Show Gist options
  • Select an option

  • Save devn/461365 to your computer and use it in GitHub Desktop.

Select an option

Save devn/461365 to your computer and use it in GitHub Desktop.
require "./lib/slugalizer/slugalizer.rb"
desc "Create a new blog post"
task :new_post, [:title] do |t, args|
created_at = Time.now.strftime("%Y-%m-%d")
slugged_title = Slugalizer.slugalize(args.title)
yaml_head = "---\nlayout: post\ntitle: #{args.title}\ndate: #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}\n---\n\n"
Dir.chdir("_posts")
File.open("#{created_at}-#{slugged_title}.markdown", 'w') { |f| f.write(yaml_head) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment