From 8ee4dc7cf67f81cf924329e9af6c349cba908655 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:22:44 -0300 Subject: [PATCH 1/2] incorporar las traducciones en env.js --- env.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/env.js b/env.js index 6210493..b38f2f9 100644 --- a/env.js +++ b/env.js @@ -6,3 +6,7 @@ window.env = { AIRBRAKE_PROJECT_KEY: '{{ site.env.AIRBRAKE_PROJECT_KEY }}', JEKYLL_ENV: '{{ site.env.JEKYLL_ENV }}' } + +window.site = { + "i18n": {{ site.i18n | jsonify }} +} From d452a85d09129877fa0fe313f7004944decbd45c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:23:50 -0300 Subject: [PATCH 2/2] buscar las traducciones en window --- _packs/controllers/notification_controller.js | 16 +--------------- _packs/controllers/search_controller.js | 11 +---------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/_packs/controllers/notification_controller.js b/_packs/controllers/notification_controller.js index 17eaaa7..d00bfd4 100644 --- a/_packs/controllers/notification_controller.js +++ b/_packs/controllers/notification_controller.js @@ -19,7 +19,7 @@ export default class extends Controller { if (!response.ok) return - data.site = await this.site() + data.site = window.site const template = await response.text() const html = await this.engine.parseAndRender(template, data) @@ -63,18 +63,4 @@ export default class extends Controller { 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 - } } diff --git a/_packs/controllers/search_controller.js b/_packs/controllers/search_controller.js index e85de43..0303601 100644 --- a/_packs/controllers/search_controller.js +++ b/_packs/controllers/search_controller.js @@ -47,7 +47,7 @@ export default class extends Controller { const main = document.querySelector('main') 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 template = await request.text() const html = await this.engine.parseAndRender(template, { q, site, results }) @@ -98,13 +98,4 @@ export default class extends Controller { return window.liquid } - - async site () { - if (!window.site) { - const data = await fetch('assets/data/site.json') - window.site = await data.json() - } - - return window.site - } }