Last active
August 29, 2015 14:27
-
-
Save erdemtu/3b44d7f4b69c618b7a02 to your computer and use it in GitHub Desktop.
A Rakefile for making a few jekyll and github-pages tasks easier. v0.1
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
require 'time' | |
# Get and parse the date | |
DATE = Time.now.strftime("%Y-%m-%d") | |
POST_TIME = Time.now.strftime("%Y-%m-%d %H:%M:%S %z") | |
desc 'create a new post' | |
task :post, :title do |t, args| | |
title = args[:title] | |
slug = "#{DATE}-#{title.downcase.gsub(/[^\w]+/, '-')}" | |
file = File.join( | |
File.dirname(__FILE__), | |
'_posts', | |
slug + '.md' | |
) | |
File.open(file, "w") do |f| | |
f << <<-EOS.gsub(/^ /, '') | |
--- | |
layout: post | |
title: "#{title}" | |
date: #{POST_TIME} | |
categories: | |
--- | |
EOS | |
end | |
system ("#{ENV['EDITOR']} #{file}") | |
end | |
desc 'Run serve' | |
task :serve do | |
sh 'bundle exec jekyll serve' | |
end | |
desc 'Run build' | |
task :build do | |
sh 'bundle exec jekyll build' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment