Skip to content

Instantly share code, notes, and snippets.

@jeremywrowe
Created February 16, 2014 03:06
Show Gist options
  • Save jeremywrowe/9028674 to your computer and use it in GitHub Desktop.
Save jeremywrowe/9028674 to your computer and use it in GitHub Desktop.
Jekyll Rake task for making a new post
desc 'creates a new post prefixed with the current date'
task :post, :name, :title, :categories do |task, args|
File.open(File.join('_posts', Time.now.strftime("%Y-%m-%d-#{args[:name].split(' ').join('-')}.markdown")), 'w') do |file|
file << <<-DOC
---
layout: post
title: "#{args[:title].downcase}"
date: #{Time.now.strftime("%Y-%m-%d-%H:%M:%S")}
categories: #{args[:categories].downcase}
---
DOC
end
end
@jeremywrowe
Copy link
Author

usage: rake 'post[the learning tree, the learning tree, learning development]'

@jeremywrowe
Copy link
Author

rake -T #=> rake post[name,title,categories] # creates a new post prefixed with the current date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment