sutty-base-jekyll-theme/env.js

54 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2021-03-26 16:14:46 +00:00
---
---
window.env = {
AIRBRAKE_PROJECT_ID: {{ site.env.AIRBRAKE_PROJECT_ID | default: 0 }},
AIRBRAKE_PROJECT_KEY: '{{ site.env.AIRBRAKE_PROJECT_KEY }}',
2021-06-01 21:33:49 +00:00
JEKYLL_ENV: '{{ site.env.JEKYLL_ENV }}',
SPREE_URL: '{{ site.env.SPREE_URL }}'
};
2021-10-27 18:22:44 +00:00
{% comment %}
Genera un site.json con las traducciones del sitio y los datos de los
pasos del carrito. No los extraemos directamente con el filtro
`jsonify` porque extraen demasiada información y el JSON se rompe.
{% endcomment %}
{%- assign steps = 'cart,shipment,payment,confirmation' | split: ',' -%}
2021-10-27 18:22:44 +00:00
window.site = {
{%- for step in steps -%}
"{{ step }}": {
{%- for attribute in site.data.layouts[step] -%}
{%- assign attribute_key = attribute[0] -%}
"{{ attribute_key }}": {{ site[step][attribute_key] | jsonify }}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
},
{%- endfor -%}
2021-10-27 18:22:44 +00:00
"i18n": {{ site.i18n | jsonify }}
};
{%- comment -%}
Para agregar plantillas que se procesan con JS, las agregamos en
Liquid dentro de assets/templates/ y luego las importamos acá, de forma
que estén disponibles para JS sin tener que descargarlas.
Es importante que la plantilla esté envuelta por el tag `raw`,
para que no sea procesado en el momento de generar env.js, sino en el
navegador.
{%- endcomment -%}
{%- capture alert %}{% include_relative assets/templates/alert.html %}{% endcapture -%}
{%- capture results %}{% include_relative assets/templates/results.html %}{% endcapture -%}
2021-10-28 13:00:00 +00:00
{%- capture cart %}{% include_relative assets/templates/cart.html %}{% endcapture -%}
{%- capture payment_methods %}{% include_relative assets/templates/payment_methods.html %}{% endcapture -%}
{%- capture recover_order %}{% include_relative assets/templates/recover_order.html %}{% endcapture -%}
{%- capture shipping_methods %}{% include_relative assets/templates/shipping_methods.html %}{% endcapture -%}
window.templates = {
2021-10-27 19:47:18 +00:00
"alert": {{ alert | jsonify }},
"results": {{ results | jsonify }},
2021-10-28 13:00:00 +00:00
"cart": {{ cart | jsonify }},
"payment_methods": {{ payment_methods | jsonify }},
"recover_order": {{ recover_order | jsonify }},
"shipping_methods": {{ shipping_methods | jsonify }},
};