volpe/_includes/recipe.njk

66 lines
No EOL
1.8 KiB
Text

---
layout: base.njk
---
<article class="recipe">
{% if isDraft %}
<div class="draft-warning-banner">
⚠️ This recipe is still a draft and may be incomplete or subject to changes.
</div>
{% endif %}
<header class="recipe-header">
<h1>{{ title }}</h1>
{% if isDraft %}
<span class="draft-badge">Draft</span>
{% endif %}
<p class="recipe-version">Version {{ recipeVersion }}</p>
{% if amount %}
<p class="recipe-amount">Amount: {{ amount }}</p>
{% endif %}
{% if cookingTime %}
<p class="recipe-cooking-time">Cooking Time: {{ cookingTime }}</p>
{% endif %}
</header>
<div class="recipe-content">
{{ content | safe }}
</div>
{% set recipeTags = page.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 %}
{% if not isDraft and isNewestVersion %}
<p class="recipe-permalink">
Permalink: <a href="/recipe/{{ recipeSlug }}/">/recipe/{{ recipeSlug }}/</a>
</p>
{% endif %}
{% set recipeData = collections.recipesBySlug[recipeSlug] %}
{% 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 version.url != page.url %}
<a href="{{ version.url }}">v{{ version.data.recipeVersion }}</a>{% if not loop.last %}, {% endif %}
{% endif %}
{% endfor %}
</p>
</aside>
{% endif %}
</article>