-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
38 lines (32 loc) · 998 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'rubygems'
require 'rake'
require 'fileutils'
require 'stringex'
posts_dir = "_posts" # directory for blog files
new_post_ext = "markdown" # default new post file extension when using the new_post task
# usage rake new
desc "Begin a new post in #{posts_dir}"
task :new do
require './_plugins/titlecase.rb'
puts "What should we call this post for now?"
name = STDIN.gets.chomp
mkdir_p "#{posts_dir}"
title = name
filename = "#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
system "mkdir -p #{posts_dir}/";
post.puts "---"
post.puts "layout: post"
post.puts "title: \"#{title.gsub(/&/,'&').titlecase}\""
post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
post.puts "comments: true"
post.puts "categories: "
post.puts "---"
end
end
desc "Startup Jekyll"
task :start do
sh "jekyll --server"
end
task :default => :start