Script to Generate a Jekyll Post
I made a quick script to generate the boilerplate for a new Jekyll post.
#!/usr/bin/env ruby
title = ARGV.join(" ")
slug = title.downcase.gsub(/[^a-z0-9]/, '_')
filename = Time.now.strftime("%Y-%m-%d") + '-' + slug + '.markdown'
front_matter = %(---
layout: post
title: "#{title}"
date: #{Time.now.strftime('%Y-%m-%d %H:%M:%S %z')}
categories:
tags:
---
)
path = "src/_posts/" + filename
File.open(path, "w+") do |fp|
fp.write(front_matter)
end