This repository has been archived by the owner on Dec 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
/
config.rb
74 lines (60 loc) · 1.71 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
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'tilt/tent_doc'
require 'markdown_html'
require 'builder'
begin
# Reload the browser automatically whenever files change
require 'middleman-livereload'
activate :livereload
rescue LoadError
end
activate :blog do |blog|
blog.permalink = "blog/:title.html"
blog.sources = "blog/:title.html"
blog.layout = 'blog_layout'
blog.default_extension = '.md'
blog.paginate = true
blog.page_link = "pages/:num"
blog.publish_future_dated = true
end
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
set :markdown_engine, :redcarpet
set :markdown, REDCARPET_EXTENTIONS
helpers do
def nav_link_with_active(text, target, attributes = {})
target_path = target
item_path = current_page.url.sub(/([^\/]+)\/\Z/, '\1')
active = if attributes.delete(:top)
/^#{target_path}/ =~ item_path
else
target_path == item_path
end
"<li #{'class="active"' if active}>" + link_to(text, target, attributes) + "</li>"
end
end
# Configure Sprockets
require 'fly'
Fly::Sprockets.setup(sprockets)
require 'sprockets-helpers'
::Sprockets::Helpers.configure do |config|
config.environment = sprockets
end
sprockets.context_class.class_eval do
include ::Sprockets::Helpers
alias _font_path font_path
def font_path(source, options = {})
options[:prefix] = "/fonts"
_path = asset_path source, ::Sprockets::Helpers.default_path_options[:font_path].merge(options)
_path
end
end
# Build-specific configuration
configure :build do
activate :minify_css
activate :minify_javascript
activate :asset_hash
activate :gzip
end