-
Notifications
You must be signed in to change notification settings - Fork 21
/
config.rb
86 lines (71 loc) · 1.9 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
Dotenv.load
I18n.enforce_available_locales = false
set :build_dir, 'docs'
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
activate :directory_indexes
ignore '/archives/*'
page '/google386369349e5ac941.html', directory_index: false
configure :build do
activate :minify_css
activate :minify_javascript
end
before_build do |builder|
dir = "#{config[:build_dir]}/archives"
builder.thor.say_status :remove, dir, :red
system "rm -rf #{dir}"
end
after_build do |builder|
src = "#{config[:source]}/archives"
dst = "#{config[:build_dir]}/archives"
builder.thor.say_status :copy, "#{src} -> #{dst}", :green
system "cp -R #{src} #{dst}"
end
after_build do |builder|
`/usr/bin/afplay /System/Library/Sounds/Tink.aiff`
end
helpers do
def site_title
'Compiling a Web Development Environment on macOS'
end
def short_site_title
'Mac Dev Env'
end
def site_desc
'A guide for compiling a web development environment on macOS.'
end
def page_title(separator = '-')
if current_resource.data.title.nil?
site_title
elsif separator == ':'
short_site_title + ": #{current_resource.data.title}"
else
site_title.prepend("#{current_resource.data.title} #{separator} ")
end
end
def page_desc
if current_resource.data.title.nil?
site_desc
else
site_desc.chomp('.') + ": #{current_resource.data.title}."
end
end
def page_id
current_page.path.split('.').first
end
end
class TableOfContents < Middleman::Extension
def initialize(app, options_hash={}, &block)
super
app.before_render do |body, path, locs, template_class|
if body.include?('{{ toc }}')
contents = File.read('source/layouts/toc.md')
toc = Kramdown::Document.new(contents).to_html
body.gsub!('{{ toc }}', toc)
end
end
end
end
::Middleman::Extensions.register(:toc, TableOfContents)
activate :toc