-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
90 lines (70 loc) · 2.37 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
#Bootstrap is used to style bits of the demo. Remove it from the config, gemfile and stylesheets to stop using bootstrap
require "uglifier"
# Activate and configure extensions
# https://middlemanapp.com/advanced/configuration/#configuring-extensions
# Use '#id' and '.classname' as div shortcuts in slim
# http://slim-lang.com/
Slim::Engine.set_options shortcut: {
'#' => {tag: 'div', attr: 'id'},
'.' => {tag: 'div', attr: 'class'}
}
activate :autoprefixer do |prefix|
prefix.browsers = "last 2 versions"
end
activate :livereload
# Layouts
# https://middlemanapp.com/basics/layouts/
# Per-page layout changes
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
page "/partials/*", layout: false
page "/admin/*", layout: false
activate :blog do |blog|
blog.permalink = "news/{year}/{title}.html"
blog.sources = "posts/{title}.html"
blog.layout = "news-detail"
end
# With alternative layout
# page '/path/to/file.html', layout: 'other_layout'
# Proxy pages
# https://middlemanapp.com/advanced/dynamic-pages/
# proxy product.yml files to product.html
data.products.each do |product|
# product is an array: [filename, {data}]
proxy "/product/#{product[1][:title].parameterize}/index.html", "product.html",
locals: {product: product[1]},
layout: 'product-detail',
ignore: true
end
# Helpers
# Methods defined in the helpers block are available in templates
# https://middlemanapp.com/basics/helper-methods/
# pretty urls
activate :directory_indexes
helpers do
#helper to set background images with asset hashes in a style attribute
def background_image(image)
"background-image: url('" << image_path(image) << "')"
end
def nav_link(link_text, url, options = {})
options[:class] ||= ""
options[:class] << " active" if url == current_page.url
link_to(link_text, url, options)
end
def markdown(content)
Tilt['markdown'].new { content }.render
end
end
# Build-specific configuration
# https://middlemanapp.com/advanced/configuration/#environment-specific-settings
configure :build do
# Minify css on build
activate :minify_css
# Minify Javascript on build
activate :minify_javascript, :ignore => "**/admin/**", compressor: ::Uglifier.new(mangle: true, compress: { drop_console: true }, output: {comments: :none})
# Use Gzip
activate :gzip
#Use asset hashes to use for caching
#activate :asset_hash
end