Created
August 25, 2012 16:50
-
-
Save sergeylukin/3467823 to your computer and use it in GitHub Desktop.
Ruby script for creating New Draft Post in Jekyll
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
#!/usr/bin/env ruby | |
unless ARGV[0] | |
puts 'Usage: newdraft "the draft title"' | |
exit(-1) | |
end | |
date_prefix = Time.now.strftime("%Y-%m-%d") | |
post_name = ARGV.join ' ' | |
post_file_name = post_name.strip.downcase.gsub(/ /, '-') | |
post = "./_posts/#{date_prefix}-#{post_file_name}.draft.md" | |
header = <<-END | |
--- | |
layout: post | |
tags: | |
title: "#{post_name}" | |
--- | |
Write the "#{post_name}" content here... | |
END | |
File.open(post, 'w') do |f| | |
f << header | |
end | |
system("vim #{post}") | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment