This repository has been archived by the owner on May 26, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 871
/
config.rb
95 lines (76 loc) · 2.02 KB
/
config.rb
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
require 'redcarpet'
require 'active_support'
require 'active_support/core_ext'
require 'support-for'
Dir['./lib/*'].each { |f| require f }
ignore /[a-z]{2}-[A-Z]{2}$/
# Debugging
set(:logging, ENV['RACK_ENV'] != 'production')
activate :relative_assets
set :relative_links, true
set :markdown_engine, :redcarpet
set :markdown, :layout_engine => :erb,
:fenced_code_blocks => true,
:lax_html_blocks => true,
:renderer => Highlighter::HighlightedHTML.new
activate :directory_indexes
activate :toc
activate :highlighter
activate :alias
def current_guide(mm_instance, current_page)
path = current_page.path.gsub('.html', '')
guide_path = path.split("/")[0]
current_guide = mm_instance.data.pages.find do |guide|
guide.url == guide_path
end
current_guide
end
def current_chapter(mm_instance, current_page)
guide = current_guide(mm_instance, current_page)
return unless guide
path = current_page.path.gsub('.html', '')
chapter_path = path.split('/')[1..-1].join('/')
current_chapter = guide.pages.find do |chapter|
chapter.url == chapter_path
end
current_chapter
end
###
# Build
###
configure :build do
set :spellcheck_allow_file, "./data/spelling-exceptions.txt"
activate :spellcheck, ignore_selector: '.CodeRay', page: /^(?!.*stylesheets|.*javascript|.*fonts|.*images|.*analytics).*$/
activate :minify_css
activate :minify_javascript, ignore: /.*examples.*js/
activate :html_proofer
end
###
# Pages
###
page '404.html', directory_index: false
# Don't build layouts standalone
ignore '*_layout.erb'
###
# Helpers
###
helpers do
# Workaround for content_for not working in nested layouts
def partial_for(key, partial_name=nil)
@partial_names ||= {}
if partial_name
@partial_names[key] = partial_name
else
@partial_names[key]
end
end
def rendered_partial_for(key)
partial_name = partial_for(key)
partial(partial_name) if partial_name
end
def page_classes
classes = super
return 'not-found' if classes == '404'
classes
end
end