volpe/recipe.njk

69 lines
No EOL
2 KiB
Text

---
pagination:
data: collections.recipesBySlug
size: 1
alias: slugData
resolve: keys
permalink: /recipe/{{ slugData }}/
layout: base.njk
pageType: recipe
excludeFromSitemap: true
eleventyComputed:
title: "{{ collections.recipesBySlug[slugData].newest.data.title }}"
---
{% set recipeData = collections.recipesBySlug[slugData] %}
{% set recipe = recipeData.newest %}
{% if recipe %}
<article class="recipe">
{% if recipe.data.plantBased === false %}
<div class="warning-banner">
This recipe contains products of animal agriculture. Animal agriculture is a significant contributor to greenhouse gas emissions, deforestation, water pollution, and worker exploitation. Consider exploring plant-based alternatives to reduce negative impacts.
</div>
{% endif %}
<header class="recipe-header">
<h1>{{ recipe.data.title }}</h1>
</header>
<div class="measurement-toggles" style="display: none;"></div>
<div class="recipe-content">
{{ recipe.content | renderRecipeMarkdown | safe }}
</div>
{% set recipeTags = recipe.inputPath | extractTagsFromFile %}
{% if recipeTags.length > 0 %}
<section class="recipe-tags">
<h2>Tags</h2>
<ul class="tag-list">
{% for tag in recipeTags %}
<li><a href="/tags/{{ tag | lower }}/">#{{ tag }}</a></li>
{% endfor %}
</ul>
</section>
{% endif %}
{% set nonDraftVersions = [] %}
{% for version in recipeData.versions %}
{% if not version.data.isDraft %}
{% set nonDraftVersions = (nonDraftVersions.push(version), nonDraftVersions) %}
{% endif %}
{% endfor %}
{% if nonDraftVersions.length > 1 %}
<aside class="recipe-other-versions">
<p>Other versions:
{% for version in nonDraftVersions %}
{% if not version.data.isNewestVersion %}
<a href="{{ version.url }}">v{{ version.data.recipeVersion }}</a>{% if not loop.last %}, {% endif %}
{% endif %}
{% endfor %}
</p>
</aside>
{% endif %}
</article>
{% else %}
<p>No published recipe found for this slug.</p>
{% endif %}