-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconfig.rb
More file actions
95 lines (77 loc) · 2.27 KB
/
config.rb
File metadata and controls
95 lines (77 loc) · 2.27 KB
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
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
#
# With no layout
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
# With alternative layout
# page "/path/to/file.html", layout: :otherlayout
data.workshops.speakers.each do |speaker|
slug = speaker.full_name.gsub(" ", "-").downcase
proxy "/workshops/#{slug}/index.html", "/workshops/template.html", locals: {
speaker: speaker }, ignore: true
end
# General configuration
# Reload the browser automatically whenever files change
configure :development do
activate :livereload
end
###
# Helpers
###
# Methods defined in the helpers block are available in templates
helpers do
def markdown(text)
return unless text
Tilt['markdown'].new(context: @app) { text }.render
end
end
# Build-specific configuration
configure :build do
# Minify CSS on build
activate :minify_css
# Minify Javascript on build
activate :minify_javascript
end
activate :asset_hash
helpers do
def primaryDomain
# CONTEXT is a read-only env variable provided by netlify. If we're on netlify, we can figure out our
# domain via the following env variables.
# See more at https://docs.netlify.com/configure-builds/environment-variables/#read-only-variables
case ENV["CONTEXT"]
when 'production'
return ENV["URL"]
when 'branch-deploy'
return ENV["DEPLOY_PRIME_URL"]
when 'deploy-preview'
return ENV["DEPLOY_PRIME_URL"]
else
# If we're NOT on netlify, either use DOMAIN or just return empty string
if ENV["DOMAIN"]
return ENV["DOMAIN"]
else
return ''
end
end
end
def imgixUrl(path,params={})
defaultParams = {auto: 'compress,format'}
params.merge!(defaultParams)
if !ENV["IMGIX_DOMAIN"] || !ENV["IMGIX_TOKEN"]
return image_path(path)
end
imgixClient = Imgix::Client.new(domain: ENV["IMGIX_DOMAIN"], secure_url_token: ENV["IMGIX_TOKEN"])
domain = primaryDomain()
if domain
return imgixClient.path(domain + image_path(path)).to_url(params)
elsif ENV["IMGIX_SOURCE_DOMAIN"]
return imgixClient.path(ENV["IMGIX_SOURCE_DOMAIN"] + image_path(path)).to_url(params)
else
return image_path(path)
end
end
end