Created
May 22, 2014 17:59
-
-
Save zvlex/30af843b2313c0638442 to your computer and use it in GitHub Desktop.
Jekyll-s rake post:new
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :post do | |
desc 'create a new jekyll post' | |
task :new do | |
title = ENV['title'] | |
time = Time.now | |
slug = "#{time.strftime("%Y-%m-%d")}#{title.downcase.gsub(/[^\w]+/, '-')}" | |
file = File.join( | |
File.dirname(__FILE__), | |
'_posts', | |
slug + '.markdown' | |
) | |
File.open(file, "w") do |f| | |
f << <<-EOS.gsub(/^ /, '') | |
--- | |
layout: post | |
title: #{title} | |
date: #{time.strftime("%Y-%m-%d %H:%M:%S")} | |
categories: [] | |
--- | |
EOS | |
end | |
puts "#{file} created! - ok" | |
system ("#{ENV['EDITOR']} #{file}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment