-
Notifications
You must be signed in to change notification settings - Fork 56
/
Rules
executable file
·125 lines (105 loc) · 2.8 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env ruby
# frozen_string_literal: true
preprocess do
config[:nanoc_version_info] = Nanoc::Core.version_information.strip
config[:nanoc_version_info_major_minor] = Nanoc::Core.version_information.strip.scan(/\d+/).take(2).join('.')
config[:nanoc_version_info_major] = Nanoc::Core.version_information.strip.scan(/\d+/).first
config[:gem_version_info] = Gem::VERSION
config[:ruby_version_info] = `ruby --version`.strip
config[:generate_pdf] = !ENV['PDF'].nil?
end
layout '/**/*', :erb
passthrough '/_redirects'
ignore '/**/_*'
passthrough '/favicon.ico'
ignore '/assets/style/*.tex'
compile '/well-known/**/*' do
write '/.' + item.identifier.to_s[1..-1]
end
compile '/assets/images/hero/*' do
write item.identifier.without_ext + '-' + fingerprint('/assets/images/hero/*') + '.' + item.identifier.ext
end
passthrough '/assets/images/**/*'
compile '/assets/style/*' do
filter :dart_sass
filter :relativize_paths, type: :css
filter :rainpress
write item.identifier.without_ext + '-' + fingerprint('/assets/style/*') + '.css'
end
compile '/sitemap.xml.*' do
filter :erb
write '/sitemap.xml'
end
compile '/robots.*' do
filter :erb
write '/robots.txt'
end
compile '/index.*' do
filter :erb
layout '/default.*'
filter :relativize_paths, type: :html
filter :cleanup_meta_charset
write '/index.html'
end
compile '/404.*' do
filter :dmark2html
layout '/default.*'
filter :cleanup_meta_charset
write '/404.html'
end
compile '/release-notes.*' do
filter :fix_contributor_brackets
filter :kramdown, auto_ids: false
filter :add_ids_to_headers
filter :autolink_github_gitlab
layout '/default.*'
filter :add_toc
filter :relativize_paths, type: :html
filter :cleanup_meta_charset
write item.identifier.without_ext + '/index.html'
end
compile '/**/*', rep: :latex do
if config[:generate_pdf] && item.identifier =~ '/doc/**/*'
case item.identifier.ext
when 'erb'
filter :erb
when 'dmark'
filter :dmark2latex
when nil # rubocop:disable Lint/EmptyWhen
else
raise
end
layout '/latex-chapter.erb'
end
end
compile '/book.*' do
if config[:generate_pdf]
filter :erb
layout '/latex-book.erb'
filter :latex2pdf
write item.identifier.without_ext + '.pdf'
end
end
compile '/**/*' do
case item.identifier.ext
when 'erb'
filter :erb
filter :add_ids_to_headers
when 'dmark'
filter :dmark2html
else
filter :add_ids_to_headers
end
layout '/default.*'
filter :add_toc
filter :relativize_paths, type: :html
filter :cleanup_meta_charset
if item.binary?
write item.identifier.to_s
elsif item.identifier =~ '/doc/about.*'
# TODO: Remove me, and set up a redirect from /about to /doc/about
write '/about/index.html'
else
write item.identifier.without_ext + '/index.html'
end
end