-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconfig.rb
94 lines (75 loc) · 1.89 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
require 'rdiscount'
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
#
# With no layout
page "/components/*", layout: false
#
# With alternative layout
# page "/path/to/file.html", :layout => :otherlayout
#
# A path which all have the same layout
# with_layout :admin do
# page "/admin/*"
# end
# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/)
# proxy "/this-page-has-no-template.html", "/template-file.html", :locals => {
# :which_fake_page => "Rendering a fake page with a local variable" }
###
# Helpers
###
helpers do
def markdown(string)
RDiscount.new(string).to_html.delete("\n")
end
# Like I18n.t but parses markdown
def m(i18n)
markdown(I18n.t(i18n))
end
# Rails like path helpers
# e.g. home_path => /#/home
%W(home guide calculator share).each do |p|
define_method("#{p}_path") do
"/#/#{p}"
end
end
end
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes
# Reload the browser automatically whenever files change
configure :development do
activate :livereload, :host => "localhost"
end
activate :i18n
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
module RequireJS
class << self
def registered(app)
app.after_build do |builder|
exec('node r.js -o build.js');
end
end
alias :included :registered
end
end
::Middleman::Extensions.register(:requirejs, RequireJS)
# Build-specific configuration
configure :build do
# For example, change the Compass output style for deployment
activate :minify_css
# Minify Javascript on build
# activate :minify_javascript
#
# # build js
activate :requirejs
# Enable cache buster
# activate :asset_hash
# Or use a different image path
# set :http_prefix, "/Content/images/"
# optimise image files on build
activate :imageoptim
end