-
Notifications
You must be signed in to change notification settings - Fork 20
/
Rules
68 lines (61 loc) · 1.72 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
compile '/guide/' do
filter :haml
end
ignore '*/_*'
preprocess do
next if ENV['NANOC_ENV'] == 'development'
puts "Preprocessing"
Nanoc::Filters::AlgoliaFilter.new(config: config).destroy_index
puts "Index destroyed"
end
compile '*' do
if item.identifier == '/_common_links/'
nil
elsif item.binary?
"#{item.identifier.chop}.#{item[:extension]}"
else
ext = item[:extension].nil? ? nil : item[:extension].split('.').last
case ext
when 'markdown', 'md'
filter :erb unless item.attributes[:skip_erb]
filter :algolia, preview: false unless ENV['NANOC_ENV'] == 'development' ||
item.attributes[:no_index] ||
(item.attributes[:redirect_to] && !item.attributes[:force_index])
filter :common_marker
layout 'application'
when 'scss'
filter :sprockets, css_compressor: :scss
when 'haml'
filter :haml, format: :html5
layout 'application'
when 'xml'
filter :erb
when 'js', 'txt', 'json', 'css'
filter :erb
item.identifier.chop + '.' + ext
else
raise "Unknown filetype #{item[:extension]}"
end
end
end
route '*' do
raise "Item without extension #{item.inspect}" if item[:extension].nil?
if item.identifier == '/_common_links/'
nil
elsif item.binary?
"#{item.identifier.chop}.#{item[:extension]}"
else
ext = item[:extension].nil? ? nil : item[:extension].split('.').last
case ext
when 'scss'
item.identifier.chop + '.css'
when 'js', 'txt', 'json', 'css', 'xml'
item.identifier.chop + '.' + ext
else
item.identifier + 'index.html'
end
end
end
layout '/application/', :haml, format: :html5, encoding: 'utf-8'
layout '/sidebar/', :haml, encoding: 'utf-8'
layout '*', :erb