Created
May 19, 2010 11:30
-
-
Save markoa/406206 to your computer and use it in GitHub Desktop.
Creates a blank textile file with basic YAML front matter for a Jekyll blog, launches editor.
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
#!/usr/bin/env ruby | |
# Creates a blank textile file with basic YAML front matter for | |
# your Jekyll blog. Then it launches gvim so that you can start | |
# writing immediately. | |
# | |
# Assumes your posts are in ./blog/_posts and that you're using a layout | |
# called 'post'. | |
if ARGV.empty? | |
puts "As an argument, write your new post's title. Eg 'newpost Something I want to share'." | |
exit | |
end | |
title = ARGV.join(" ") | |
slug = title.gsub(/\s+/, '-').downcase | |
path = "blog/_posts/#{Time.now.strftime("%Y-%m-%d")}-#{slug}.textile" | |
File.open(path, "w") do |f| | |
f.write "---\n" | |
f.write "title: #{title}\n" | |
f.write "layout: post\n" | |
f.write "---\n\n" | |
end | |
puts "=> #{path}" | |
`gvim #{path}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment