-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.rb
108 lines (82 loc) · 3.83 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
96
97
98
99
100
101
102
103
104
105
106
107
108
# --------------------------------------------------------------------------------------------------
# Helpers
# --------------------------------------------------------------------------------------------------
helpers do
# Helpers are defined in and can be added to `helpers/custom_helpers.rb`.
# In case you require helpers within `config.rb`, they can be added here.
end
# --------------------------------------------------------------------------------------------------
# Extensions
# --------------------------------------------------------------------------------------------------
# Use LiveReload
activate :livereload
# Use Search Engine Sitemap
set :url_root, data.config.site.root_url
activate :search_engine_sitemap
# User Bower to manage vendor scripts
activate :bower
# Split up each required asset into its own script/style tag instead of combining them
set :debug_assets, true
# --------------------------------------------------------------------------------------------------
# Paths
# --------------------------------------------------------------------------------------------------
set :css_dir, 'stylesheets'
set :fonts_dir, 'fonts'
set :images_dir, 'images'
set :js_dir, 'javascripts'
# Pretty URLs - See https://middlemanapp.com/advanced/pretty_urls/
activate :directory_indexes
# Okay Geeze
# First, we sort the dates hash to be in the correct date order
# Then we do each_with_index to get the idex
trip_dates = data.dates.sort{ |a, b| a.to_s.downcase <=> b.to_s.downcase }
data.dates.sort{ |a, b| a.to_s.downcase <=> b.to_s.downcase }.each_with_index do | (slug,date), index |
# Replace '-' with '/' in filename
path = slug.gsub('-', '/')
# Populate prev/next dates
prev_date = index == 0 ? nil : trip_dates[index - 1]
next_date = (index + 1) == trip_dates.length ? nil : trip_dates[index + 1]
proxy "#{path}.html", "/day/template.html", locals: { slug: slug, date: date, index: index, next_date: next_date, prev_date: prev_date }, ignore: true
end
# Add places
places = data.places
meals = data.meals.select{ | id, meal | meal.location != 'Flight' && meal.location != 'na' }
all_locations = places.merge(meals)
places_by_location = all_locations.group_by{ |id, place| place.location }.sort{ |a, b| a.to_s.downcase <=> b.to_s.downcase }
places_by_location.each do | location, places |
proxy "places/#{location.parameterize("-")}.html", "/places/template.html", locals: { location: location, places: places }, ignore: true
end
# --------------------------------------------------------------------------------------------------
# Build configuration
# --------------------------------------------------------------------------------------------------
configure :build do
# Exclude any vendor components (bower or custom builds) in the build
ignore 'stylesheets/vendor/*'
ignore 'javascripts/vendor/*'
activate :autoprefixer do |config|
config.browsers = ['last 2 versions', 'Explorer >= 9', 'Firefox 15']
config.cascade = true
end
activate :gzip
# Minify CSS
activate :minify_css
# Minify Javascript
activate :minify_javascript
# Minify HTML
activate :minify_html, remove_http_protocol: false,
remove_https_protocol: false,
remove_input_attributes: false,
remove_quotes: false
# Compress images (default)
require 'middleman-smusher'
activate :smusher
# Compress ALL images (advanced)
# Before activating the below, follow setup instructions on https://github.com/toy/image_optim
# activate :imageoptim do |options|
# options.pngout = false # set to true when pngout is also installed
# end
# Uniquely-named assets (cache buster)
# Exception: svg & png in images folder because they need to be interchangeable by JS
activate :asset_hash, ignore: [%r{images/(.*\.png|.*\.svg)$}i]
activate :build_cleaner
end