This repository has been archived by the owner on Jul 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.rb
71 lines (59 loc) · 1.52 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
require './lib/formatting_helpers'
require './lib/api_docs'
# Activate and configure extensions
activate :directory_indexes
activate :formatting_helpers
activate :api_docs, packages: {
'convergence' => '@bigtest/convergence',
'interactor' => '@bigtest/interactor',
'react' => '@bigtest/react'
}
activate :autoprefixer do |prefix|
prefix.browsers = 'last 2 versions'
end
# Markdown rules
set :markdown,
input: 'GFM',
fenced_code_blocks: true,
hard_wrap: false
set :markdown_engine, nil
Tilt.register FormattingHelpers::KramdownTemplate, 'md', 'markdown'
# Dev-specific config
configure :development do
activate :livereload
end
# Build-specific config
configure :build do
activate :minify_css
activate :minify_javascript
activate :asset_hash
end
# Pages
page '/docs/*', layout: 'doc'
page '/guides/*', layout: 'guide'
# JS & CSS will compile with rollup
ignore '/javascripts/*'
ignore '/stylesheets/*'
# API Docs
data.docs.each do |data|
proxy "/docs/#{data.name}/index.html", 'doc.html', locals: data, ignore: true
end
# JS & CSS pipeline
activate :external_pipeline,
name: :js_css,
command: "yarn #{build? ? 'build' : 'start'}",
source: './tmp'
# Misc helpers
helpers do
def link_active?(url)
return false unless url
url = url[1..-1] if url[0] == '/'
current_page.path.start_with?(url)
end
def active_link_to(text, url, match = url)
opts = { class: [] }
opts[:class] << 'is-active' if link_active?(match)
opts[:class] = opts[:class].join(' ')
link_to(text, url, opts)
end
end