84 lines
1.5 KiB
Ruby
84 lines
1.5 KiB
Ruby
#!/usr/bin/env ruby
|
|
|
|
preprocess do
|
|
create_robots_txt
|
|
create_webmaster_tools_authentications
|
|
create_sitemap
|
|
end
|
|
|
|
compile '/assets/css/*' do
|
|
filter :cache_buster
|
|
filter :rainpress
|
|
end
|
|
|
|
route %r{^/(assets/.*|sitemap|robots|atom)/$} do
|
|
next nil if item.identifier.split('/')[-1][0,1] == '_' # partial
|
|
|
|
fp = cachebust?(item) ? fingerprint(item[:filename]) : ''
|
|
item.identifier.chop + fp + '.' + item[:extension]
|
|
end
|
|
|
|
compile '/sitemap/' do
|
|
filter :erb
|
|
end
|
|
|
|
compile '/blog/feed/' do
|
|
filter :erb
|
|
end
|
|
|
|
route '/blog/feed/' do
|
|
'/blog.xml'
|
|
end
|
|
|
|
compile %r{^/(google|robots|assets|favicon)} do
|
|
end
|
|
|
|
compile '*' do
|
|
case item[:extension]
|
|
when 'slim'
|
|
filter :slim
|
|
when 'md'
|
|
filter :schema_table
|
|
filter :api_example
|
|
filter :redcarpet, renderer: MarkdownHTML, options: {
|
|
fenced_code_blocks: true,
|
|
no_intra_emphasis: true,
|
|
autolink: true,
|
|
tables: true,
|
|
strikethrough: true,
|
|
lax_html_blocks: true,
|
|
space_after_headers: true,
|
|
superscript: true
|
|
}
|
|
end
|
|
|
|
case item.identifier
|
|
when %r{/_}
|
|
layout 'none'
|
|
when %r{^/blog/.+}
|
|
layout 'post'
|
|
when %r{^/docs/}
|
|
layout 'doc'
|
|
else
|
|
layout 'default'
|
|
end
|
|
|
|
filter :cache_buster
|
|
end
|
|
|
|
route '/' do
|
|
'/index.html'
|
|
end
|
|
|
|
route '*' do
|
|
next nil if item.identifier.split('/')[-1][0,1] == '_' # partial
|
|
|
|
if item.binary?
|
|
# Write item with identifier /foo/ to /foo.ext
|
|
item.identifier.chop + '.' + item[:extension]
|
|
else
|
|
item.identifier.chop + '.html'
|
|
end
|
|
end
|
|
|
|
layout '*', :slim
|