recipe-site/_layouts/recipe.html

34 lines
1.5 KiB
HTML
Raw Normal View History

---
layout: default
---
{%- comment -%} return everything before the first full stop, without the trailing "_recipes/". for example: "_recipes/file.yml.md" becomes "file" {%- endcomment -%}
{%- assign id = page.path | split: "." | pop | first | remove_first: "_recipes/" -%}
{%- comment -%} unfortunately we have to iterate through the entire subrecipe folder twice - once to see if there are any subrecipes that apply here, and another time to put them in. thankfully we can break out of the first loop if we find a single match. i miss jinja ;u; {%- endcomment -%}
{%- assign applicable_subrecipes = false -%}
{%- for subrecipe in site.subrecipes -%}
{%- if subrecipe.parents contains id -%}
{%- comment -%} we found one! {%- endcomment -%}
{%- assign applicable_subrecipes = true -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
<h1>{{ page.name }}</h1>
2020-02-29 20:36:58 +00:00
<p class='subtle'> {{ page.method.size }} steps - Estimated cooking time: {{ page.time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}</p>
{%- if applicable_subrecipes %}
<h2> Subrecipes </h2>
{% for subrecipe in site.subrecipes -%}
{%- if subrecipe.parents contains id -%}
<div class='subrecipe' id='sr-{{ subrecipe.name | downcase | url_encode }}'>
2020-02-29 19:01:50 +00:00
<h3>{{ subrecipe.name }}</h3>
<div class='subrecipe-output'>
{{ subrecipe.output }}
</div>
</div>
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- include ingredients.html -%}
2020-02-29 18:11:17 +00:00
{%- include method.html -%}