-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
189 lines (160 loc) · 4.35 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
require "lib/path_helpers"
require "lib/image_helpers"
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
set :url_root, ENV.fetch('BASE_URL')
ignore '/templates/*'
LOCALES = ENV['LANGS'].split(",").map(&:to_sym)
activate :i18n, langs: LOCALES, mount_at_root: LOCALES[0]
activate :asset_hash
activate :directory_indexes
activate :pagination
activate :inline_svg
activate :dato, token: ENV.fetch('DATO_API_TOKEN'), live_reload: true
# set timezone
require 'tzinfo'
Time.zone = 'Europe/Rome'
webpack_command =
if build?
"yarn run build"
else
"yarn run dev"
end
activate :external_pipeline,
name: :webpack,
command: webpack_command,
source: ".tmp/dist",
latency: 1
activate :blog do |blog|
# This will add a prefix to all links, template references and source paths
# blog.prefix = "blog"
# blog.permalink = "{year}/{month}/{day}/{title}.html"
# Matcher for blog source files
# blog.sources = "{year}-{month}-{day}-{title}.html"
# blog.taglink = "tags/{tag}.html"
# blog.layout = "layout"
# blog.summary_separator = /(READMORE)/
# blog.summary_length = 250
# blog.year_link = "{year}.html"
# blog.month_link = "{year}/{month}.html"
# blog.day_link = "{year}/{month}/{day}.html"
# blog.default_extension = ".md"
# blog.tag_template = "tag.html"
# blog.calendar_template = "calendar.html"
# Enable pagination
# blog.paginate = true
# blog.per_page = 10
# blog.page_link = "page/{num}"
end
configure :build do
activate :minify_html do |html|
html.remove_input_attributes = false
end
activate :search_engine_sitemap,
default_priority: 0.5,
default_change_frequency: 'weekly'
end
configure :development do
activate :livereload
end
helpers do
include PathHelpers
include ImageHelpers
# Custom helper to theme
def site_nav_menu
[
# dato.about_page,
# dato.contact_page
]
end
end
=begin
dato.tap do |dato|
dato.articles.each do |article|
proxy(
'/articles/#{article.slug}.html',
'/templates/article.html',
locals: { article: article }
)
end
end
=end
=begin
paginate(
dato.articles.sort_by(&:publication_date).reverse,
'/article',
'/templates/article.html'
)
=end
# MULTILANG SAMPLES
#
# langs.each do |locale|
# I18n.with_locale(locale) do
# proxy "/#{locale}/index.html",
# "/localizable/index.html",
# locals: { page: dato.homepage },
# locale: locale
#
# proxy "/#{locale}/#{dato.about_page.slug}/index.html",
# "/templates/about_page.html",
# locals: { page: dato.about_page },
# locale: locale
#
# dato.aritcles.each do |article|
# I18n.locale = locale
# proxy "/#{locale}/articles/#{article.slug}/index.html", "/templates/article_template.html", :locals => { article: article }, ignore: true, locale: locale
# end
# end
# end
# langs.each do |locale|
# I18n.with_locale(locale) do
# I18n.locale = locale
# paginate dato.articles.select{|a| a.published == true}.sort_by(&:date).reverse, "/#{I18n.locale}/articles", "/templates/articles.html", locals: { locale: I18n.locale }
# end
# end
# end
all_articles = dato.articles.sort_by(&:publication_date)
proxy "/index.html", "/templates/index.html", locals: { articles: all_articles }
dato.articles.each do |article|
proxy "/articles/#{article.slug}.html",
"/templates/article.html",
locals: { article: article }
end
=begin
dato.tap do |dato|
dato.articles.each do |article|
proxy(
"/articles/#{article.slug}.html",
"/templates/article.html",
locals: { article: article },
ignore: true
)
end
end
=end
=begin
LOCALES.each do |locale|
I18n.with_locale(locale) do
prefix = locale == LOCALES[0] ? "" : "/#{locale}"
proxy "#{prefix}/index.html",
"/localizable/index.html",
locale: locale
proxy "#{prefix}/contact/index.html",
"templates/contact_page.html",
locals: { locale: I18n.locale },
locale: locale
end
end
=end
proxy "site.webmanifest",
"templates/site.webmanifest",
:layout => false
proxy "browserconfig.xml",
"templates/browserconfig.xml",
:layout => false
proxy "/_redirects",
"/templates/redirects.txt",
:layout => false
# all_articles = dato.articles.sort_by(&:publication_date)
# proxy "/index.html", "/templates/index.html", locals: { articles: all_articles }