-
Notifications
You must be signed in to change notification settings - Fork 172
/
config.rb
140 lines (107 loc) · 2.6 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
ENV['SITE_ENV'] ||= 'development'
Bundler.require(:default, ENV['SITE_ENV']) if defined?(Bundler)
require 'yaml'
require 'ostruct'
require 'rack/utils'
require 'middleman-syntax'
require 'lib/github_style_titles'
require File.expand_path('../extensions/build_cleaner.rb', __FILE__)
activate :breadcrumbs
###
# Page options, layouts, aliases and proxies
###
page '/', layout: 'home'
page '/atom.xml', layout: false
page '/ml/*', layout: false
###
# Helpers
###
activate :directory_indexes
activate :syntax, inline_theme: Rouge::Themes::Github.new
activate :blog do |blog|
blog.prefix = 'blog'
blog.permalink = '{year}/{month}/{day}/{title}.html'
blog.layout = :blog
blog.paginate = true
blog.per_page = 5
end
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes
set :url_root, 'https://hanamirb.org'
# Methods defined in the helpers block are available in templates
helpers do
#
# BLOG
#
def blog_articles(limit = 5)
blog.articles.first(limit)
end
def article_title(article)
article.data.title
end
def article_author(article)
article.data.author
end
def article_date(article)
date = article.date
date.strftime('%B %d, %Y')
end
def article_summary(article)
article.data.excerpt
end
def article_image(article)
if article.data.image
%(<img src="#{ article_image_url(article) }" loading="lazy">)
end
end
def article_image_url(article)
path = if article.data.image
article.url.gsub(/\.html/, '')
else
"/images"
end
"#{ path }cover.jpg"
end
#
# UTILS
#
def absolute_url(page)
url = if page.respond_to?(:url)
page.url
else
page
end
"http://hanamirb.org#{ url }"
end
def encode_text(text)
::Rack::Utils.escape(text)
end
def current_ruby_version
"3.2.0"
end
def hanami_version
"2.2.0"
end
def hanami_release_date
Date.parse("2024-11-05").strftime("%B %-d, %Y")
end
end
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
set :markdown_engine, :redcarpet
set :markdown, fenced_code_blocks: true, smartypants: true, renderer: GithubStyleTitles
# Build-specific configuration
configure :build do
# For example, change the Compass output style for deployment
# activate :minify_css
# Minify Javascript on build
# activate :minify_javascript
# Enable cache buster
# activate :asset_hash
# Use relative URLs
# activate :relative_assets
# Or use a different image path
# set :http_prefix, "/Content/images/"
activate :build_cleaner
end