This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRules
111 lines (90 loc) · 2.42 KB
/
Rules
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env ruby
# Preprocess rules for item pagination
preprocess do
paginateArticles
createTagItems
end
#############################
############### COMPILE RULES
#############################
# Assets
compile '/assets/css/*.{sc,sa,c}ss' do
if item.identifier.ext == 'scss' or item.identifier.ext == 'sass'
filter :sass, { :cache => false, :style => (@config[:debug] ? :compact : :compressed) }
end
filter :yui_compressor, { :type => 'css', :munge => true, :preserve_semicolons => false, :optimize => true } unless @config[:debug]
end
# JavaScript
compile '/assets/js/*.js' do
filter :erb
filter :uglify_js, { :compress => { :drop_console => true } } unless @config[:debug]
end
# Robots.txt must be skipped
compile '/robots.txt' do
write '/robots.txt'
end
compile '/sitemap.*' do
filter :erb
end
compile '/posts/feed.*' do
filter :erb
end
compile '/*.xml' do
write item.identifier.to_s
end
compile '/**/*' do
if item.binary?
# If the item is a binary, skip it
nil
else
case item.identifier.ext
when 'md'
filter :kramdown
when 'html'
nil
else
filter :erb
end
layout '/posts.*' if item.identifier =~ /posts/
layout item[:layout] if item[:layout]
if item.identifier =~ /guide/ or item.identifier =~ /contact/ or item.identifier =~ /about/
layout '/content_without_sidebar.*'
else
layout '/content_with_sidebar.*'
end
layout '/default.*'
end
end
##############################
################ ROUTING RULES
##############################
route '/posts/feed.*' do
item.identifier.without_exts + '.xml'
end
route '/pages/1' do
'/index.html'
end
route '/assets/**/*' do
case item.identifier.ext
when 'sass', 'scss'
item.identifier.without_exts + '.' + 'css'
else
item.identifier.to_s
end
end
route '/browserconfig.*' do
item.identifier.without_ext + '.xml'
end
route '/sitemap.*' do
'/atom.xml'
end
route '/**/*' do
if item.binary?
# Write item with identifier /foo/ to /foo.ext
item.identifier.to_s
else
# Write item with identifier /foo/ to /foo/index.html
item.identifier.without_exts + '/index.html'
end
end
layout '/**/*', :slim, { :format => :html, :pretty => true, :disable_escape => true, :sort_attrs => true }