forked from tammersaleh/tammersaleh.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
71 lines (57 loc) · 1.63 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 'bootstrap-sass'
require "active_support/core_ext/array"
require 'dotenv'
Dotenv.load
set :build_dir, ".build"
set :markdown, enable_coderay: false
compass_config do |config|
config.output_style = :compact
end
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes
activate :minify_css
# This breaks the site.
# activate :minify_javascript
helpers do
# Calculate the years for a copyright
def copyright_years(start_year)
end_year = Date.today.year
if start_year == end_year
start_year.to_s
else
start_year.to_s + '-' + end_year.to_s
end
end
# Holder.js image placeholder helper
def img_holder(width, height, opts = {})
img = "<img data-src=\"holder.js/#{width}x#{height}/auto"
img << "/#{opts[:bgcolor]}:#{opts[:fgcolor]}" if opts[:fgcolor] && opts[:bgcolor]
img << "/text:#{opts[:text].gsub(/'/,"\'")}" if opts[:text]
img << "\" width=\"#{width}\" height=\"#{height}\">"
img
end
def github_edit_url
p = Pathname(current_page.source_file).relative_path_from(Pathname(root))
"https://github.com/tsaleh/tammersaleh.com/edit/master/#{p}"
end
def index_article_background_url(article)
"#{article.url}cover.png"
end
end
# Build-specific configuration
configure :build do
end
Time.zone = "Pacific Time (US & Canada)"
activate :blog do |blog|
blog.prefix = "posts"
blog.permalink = ":title.html"
blog.layout = "post"
end
page "/posts.atom", layout: false
activate :directory_indexes
activate :cache_buster
module Middleman::Blog::BlogArticle
def body_with_absolute_img_tags
body.gsub(%r{src="([^/])}, 'src="' + url + '\1')
end
end