Last active
December 14, 2015 18:59
-
-
Save return-none/5132887 to your computer and use it in GitHub Desktop.
Rakefile for new post Jekyll blogging
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
# Original idea by MattHall | |
# https://gist.github.com/MattHall/1801090 | |
# usage rake new_post title="my awesome title" | |
require 'date' | |
task :new_post do | |
title = ENV['title'] | |
path = "_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md" | |
if File.exist?(path) | |
puts "[WARN] File exists - skipping create" | |
else | |
File.open(path, 'w') do |file| | |
file.puts '---' | |
file.puts 'layout: default' | |
file.puts 'title: ' + title.capitalize | |
file.puts '---' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment