-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.rb
130 lines (108 loc) · 2.91 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
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
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
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
# dato.tap do |dato|
# dato.articles.each do |article|
# proxy(
# '/articles/#{article.slug}.html',
# '/templates/article.html',
# locals: { article: article }
# )
# end
# paginate(
# dato.articles.sort_by(&:published_at).reverse,
# '/articles',
# '/templates/articles.html'
# )
# 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
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
proxy "site.webmanifest",
"templates/site.webmanifest",
:layout => false
proxy "browserconfig.xml",
"templates/browserconfig.xml",
:layout => false
proxy "/_redirects",
"/templates/redirects.txt",
:layout => false