Update recipe page template

This commit is contained in:
TheThomaas 2025-12-24 22:16:38 +01:00
parent d786f02c9a
commit 29140453e8

View file

@ -13,15 +13,29 @@
</div>
{% set ingredientsArray = [] %}
{% for ingredient in ingredients %}
{% set value = [ingredient.quantity, ingredient.units, " ", ingredient.name] | join %}
{% set notes = "" %}
{% if ingredient.note %}
{% set notes = [" (", ingredient.note, ")"] | join %}
{% endif %}
{% set value = [ingredient.quantity.value.value.value, ingredient.quantity.unit, " ", ingredient.name, notes] | join %}
{% set ingredientsArray = (ingredientsArray.push(value), ingredientsArray) %}
{% endfor %}
<div class="c-recipe__ingredients-wrapper" x-data='{currentServings: {{ servings if not servings == "" else false }}, ingredients: decodeURI("{{ ingredientsArray | arrayToString }}").split("£") }'>
<!-- <div class="c-recipe__ingredients-wrapper" x-data='{currentServings: {{ servings if not servings == "" else false }}, ingredients: decodeURI("{{ ingredients | arrayToString }}").split("£") }'> -->
{% if time or not servings == "" %}
<div class="c-recipe__additional-info">
{% if time %}
<p>{% include "icons/time.svg" %}{{ time }}</p>
{% if time.prep %}
<p>{% include "icons/time.svg" %}Prep: {{ time.prep }}</p>
{% endif %}
{% if time.cook %}
<p>{% include "icons/time.svg" %}Cook: {{ time.cook }}</p>
{% endif %}
{% if not time.cook and not time.prep %}
<p>{% include "icons/time.svg" %}Total: {{ time }}</p>
{% endif %}
{% endif %}
{% if duration %}
<p>{% include "icons/time.svg" %}Total: {{ duration }}</p>
{% endif %}
{% if not servings == "" %}
<p>
@ -62,38 +76,39 @@
<h3>Cookware</h3>
<ul class="c-recipe__ingredients-list">
{% for ingredient in cookware %}
<li><label><input type="checkbox"><span>{{ingredient.quantity}}{{ ingredient.units}} {{ ingredient.name }}</span></label></li>
{% set notes = "" %}
{% if ingredient.note %}
{% set notes = [" (", ingredient.note, ")"] | join %}
{% endif %}
<li><label><input type="checkbox"><span>{{ingredient.quantity}}{{ ingredient.units}} {{ ingredient.name }} {{notes}}</span></label></li>
{% endfor %}
</ul>
</div>
<div class="c-recipe__instructions-wrapper u-free-text">
{% for section in sections %}
{% if section.title %}
<h3>{{ section.title.content }}</h3>
{% endif %}
<ol>
{% for steps in section.content %}
<li>
{% for items in steps %}{% if items.type == "ingredient" %}{% if items.reference %}<a href="../{{ items.reference.components | join("/") }}/{{ items.reference.name }}" target="_blank">{{items.content}}</a>{% else %}{{items.content}}{% endif %} ({{items.quantity.value.value.value}}{% if items.quantity.unit %} {{items.quantity.unit}}{% endif %}){% else %}{{items.content}}{% endif %}{% endfor %}
</li>
{% endfor %}
</ol>
{% endfor %}
{% set notesArr = notes.split('|') %}
{% if notesArr.length > 1 %}
<h3>Notes</h3>
<aside class="alert">
{%- for note in notesArr -%}
{{ note | safe }}<br>
{%- endfor -%}
</aside>
{% endif %}
<!-- {% if notes.length > 1 %}
<aside class="alert">
{%- for note in notes -%}
{{ note | safe }}
{%- endfor -%}
</aside>
{% endif %} -->
<!-- {{ content | safe }} -->
{% for step in steps %}
<p>
{% for stepDetail in step %}{{ stepDetail | safe }}{% endfor %}
</p>
{% endfor %}
<!-- {% for step in steps %}
<p>
{% for stepDetail in step %}{{ stepDetail.value | safe }}{{ stepDetail.name | safe }}{% endfor %}
</p>
{% endfor %} -->
{% if source %}
<p><a href="{{ source }}" target="_blank" rel="noopener">Source</a></p>
{% endif %}