Skip to content

Instantly share code, notes, and snippets.

@ardianzzz
Created May 5, 2012 11:25
Show Gist options
  • Save ardianzzz/2601691 to your computer and use it in GitHub Desktop.
Save ardianzzz/2601691 to your computer and use it in GitHub Desktop.
Jekyll New Post Rakefile
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
@ardianzzz
Copy link
Author

Jalankan di terminal:

$ rake write["Judul post dimari",category dimari]

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