-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
69 lines (61 loc) · 1.8 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
drafts_dir = '_drafts'
posts_dir = '_posts'
# rake post['my new post']
desc 'create a new post with "rake post[\'post title\']"'
task :post, :title do |t, args|
if args.title
title = args.title
else
puts "Please try again. Remember to include the filename."
end
mkdir_p "#{posts_dir}"
filename = "#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/[^\w]+/, '-')}.md"
puts "Creating new post: #{filename}"
File.open(filename, "w") do |f|
f << <<-EOS.gsub(/^ /, '')
---
layout: post
title: #{title}
date: #{Time.new.strftime('%Y-%m-%d %H:%M')}
categories:
---
EOS
end
# Uncomment the line below if you want the post to automatically open in your default text editor
# system ("#{ENV['EDITOR']} #{filename}")
end
# usage: rake draft['my new draft']
desc 'create a new draft post with "rake draft[\'draft title\']"'
task :draft, :title do |t, args|
if args.title
title = args.title
else
puts "Please try again. Remember to include the filename."
end
mkdir_p "#{drafts_dir}"
filename = "#{drafts_dir}/#{title.downcase.gsub(/[^\w]+/, '-')}.md"
puts "Creating new draft: #{filename}"
File.open(filename, "w") do |f|
f << <<-EOS.gsub(/^ /, '')
---
layout: post
title: #{title}
date: #{Time.new.strftime('%Y-%m-%d %H:%M')}
categories:
---
EOS
end
# Uncomment the line below if you want the draft to automatically open in your default text editor
# system ("#{ENV['EDITOR']} #{filename}")
end
desc 'preview the site with drafts'
task :preview do
puts "## Generating site"
puts "## Stop with ^C ( <CTRL>+C )"
system "jekyll serve --watch --drafts"
end
desc 'list tasks'
task :list do
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
puts "(type rake -T for more detail)\n\n"
end