-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
executable file
·63 lines (52 loc) · 1.73 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
activate :automatic_image_sizes
activate :directory_indexes
activate :livereload
activate :minify_html
activate :syntax
set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true, :smartypants => true
set :relative_links, true
# Methods defined in the helpers block are available in templates
helpers do
def get_page_priority(page)
unless page.nested?
data.priority.index(page.title) || data.priority.length
else
data.priority.index("#{ page.parent } - #{ page.title }") || data.priority.length
end
end
def get_pages
sitemap.resources.select { |resource| resource.data.type == 'page' }
.sort_by { |r| get_page_priority(r.data) }
end
def get_secondary_pages
sitemap.resources.select { |resource| resource.data.type == 'page' and resource.data.secondary? }
.sort_by { |r| get_page_priority(r.data) }
end
def get_page(priority)
sitemap.resources.select { |resource| resource.data.type == 'page' and get_page_priority(resource.data) == priority }
end
def get_nested_pages(title)
sitemap.resources.select { |resource| resource.data.type == 'page' and resource.data.nested == true and resource.data.parent == title }
.sort_by { |r| get_page_priority(r.data) }
end
def is_excluded_page(page)
page.data.nested? or page.data.children? or page.data.secondary?
end
def is_page_active(page)
current_page.url == page
end
def is_parent_page_active(page)
current_page.url.match(page)
end
end
set :css_dir, 'assets/stylesheets'
set :js_dir, 'assets/javascripts'
set :images_dir, 'assets/images'
set :fonts_dir, 'assets/fonts'
# Build-specific configuration
configure :build do
activate :minify_css
activate :minify_javascript
activate :relative_assets
end