Created
May 5, 2012 11:25
-
-
Save ardianzzz/2601691 to your computer and use it in GitHub Desktop.
Jekyll New Post Rakefile
This file contains hidden or 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
desc "Given a title as an argument, create a new post file" | |
task :write, [:title, :category] do |t, args| | |
filename = "#{Time.now.strftime('%Y-%m-%d')}-#{args.title.gsub(/\s/, '_').downcase}.markdown" | |
path = File.join("_posts", filename) | |
if File.exist? path; raise RuntimeError.new("Won't clobber #{path}"); end | |
File.open(path, 'w') do |file| | |
file.write <<-EOS | |
--- | |
layout: post | |
category: #{args.category} | |
title: #{args.title} | |
date: #{Time.now.strftime('%Y-%m-%d %k:%M:%S')} | |
--- | |
EOS | |
end | |
puts "Now open #{path} in an editor." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jalankan di terminal:
$ rake write["Judul post dimari",category dimari]