Merge branch 'site-en-env' into 'master'

Site en env

See merge request sutty/jekyll/sutty-base-jekyll-theme!21
This commit is contained in:
fauno 2021-10-28 12:35:31 +00:00
commit 0d8c585000
3 changed files with 6 additions and 25 deletions

View file

@ -19,7 +19,7 @@ export default class extends Controller {
if (!response.ok) return if (!response.ok) return
data.site = await this.site() data.site = window.site
const template = await response.text() const template = await response.text()
const html = await this.engine.parseAndRender(template, data) const html = await this.engine.parseAndRender(template, data)
@ -63,18 +63,4 @@ export default class extends Controller {
return window.liquid return window.liquid
} }
/*
* Site config (actually just translation strings)
*
* @return [Object]
*/
async site () {
if (!window.site) {
const data = await fetch('assets/data/site.json')
window.site = await data.json()
}
return window.site
}
} }

View file

@ -47,7 +47,7 @@ export default class extends Controller {
const main = document.querySelector('main') const main = document.querySelector('main')
const results = window.index.search(q).map(r => window.data.find(a => a.id == r.ref)) const results = window.index.search(q).map(r => window.data.find(a => a.id == r.ref))
const site = await this.site() const site = window.site
const request = await fetch('assets/templates/results.html') const request = await fetch('assets/templates/results.html')
const template = await request.text() const template = await request.text()
const html = await this.engine.parseAndRender(template, { q, site, results }) const html = await this.engine.parseAndRender(template, { q, site, results })
@ -98,13 +98,4 @@ export default class extends Controller {
return window.liquid return window.liquid
} }
async site () {
if (!window.site) {
const data = await fetch('assets/data/site.json')
window.site = await data.json()
}
return window.site
}
} }

4
env.js
View file

@ -6,3 +6,7 @@ window.env = {
AIRBRAKE_PROJECT_KEY: '{{ site.env.AIRBRAKE_PROJECT_KEY }}', AIRBRAKE_PROJECT_KEY: '{{ site.env.AIRBRAKE_PROJECT_KEY }}',
JEKYLL_ENV: '{{ site.env.JEKYLL_ENV }}' JEKYLL_ENV: '{{ site.env.JEKYLL_ENV }}'
} }
window.site = {
"i18n": {{ site.i18n | jsonify }}
}