-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
51 lines (39 loc) · 961 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
39
40
41
42
43
44
45
46
47
48
49
50
51
require "haml"
require "listen"
require "pandoc-ruby"
require "time"
require "./helpers"
LAYOUT = "content/layout.haml"
task default: :build
task :build do
build
end
task :listen do
listener = Listen.to(".", "content/", only: /\.md|\.haml/) do |modified, added, removed|
paths = [modified, added, removed].flatten.map { |path|
ContentFile.new(path).basename
}.join(",")
puts "Building -- ts=#{Time.now.iso8601} modified=#{paths}"
begin
build
rescue Exception => ex
puts ex
puts ex.backtrace
end
end
listener.start
sleep
end
task :deploy do
%x(aws s3 sync site s3://reinvent2017.wildrydes.com/)
end
def build
Dir["content/*"].each do |path|
next if path == LAYOUT
content_file = ContentFile.new(path)
next if content_file.partial?
File.open(File.join("site", content_file.stem + ".html"), "w") do |file|
file.write(render(LAYOUT) { render(path) })
end
end
end