-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.rb
More file actions
60 lines (48 loc) · 1.42 KB
/
config.rb
File metadata and controls
60 lines (48 loc) · 1.42 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
activate :blog do |blog|
blog.prefix = "articles"
blog.sources = "posts/{title}.html"
blog.permalink = "{title}.html"
blog.layout = "blog_layout"
blog.default_extension = ".md"
end
activate :external_pipeline do |pipeline|
pipeline.name = :esbuild
pipeline.command = build? ? "node esbuild.config.js" : "node esbuild.config.js --watch"
pipeline.source = 'tmp/dist'
pipeline.latency = 1
end
activate :syntax
activate :directory_indexes
configure :development do
activate :livereload
end
page "/sitemap.xml", layout: false
page "/404.html", directory_index: false
configure :build do
# Enable cache buster (except for images)
activate :asset_hash, ignore: [/\.jpg\Z/, /\.png\Z/]
activate :gzip
end
helpers do
def full_url(path = current_page.url)
"https://michaelkoper.com#{path}"
end
def svg(name)
root = Middleman::Application.root
file_path = "#{root}/source/images/#{name}.svg"
return File.read(file_path) if File.exists?(file_path)
'(not found)'
end
def link_to(*args, &block)
options = args.extract_options!
url = args[block_given? ? 0 : 1]
if url
target_url = url_for(url)
current_url = current_resource.url
is_current = current_url == target_url ||
(target_url.end_with?('/') && target_url != '/' && current_url.start_with?(target_url))
options['aria-current'] = :page if is_current
end
super(*args, options, &block)
end
end