feat: created recipes structure

This commit is contained in:
Leyla Becker 2026-02-12 14:57:57 -06:00
parent a035c08249
commit f93207b4e3
7 changed files with 432 additions and 13 deletions

61
recipe.njk Normal file
View file

@ -0,0 +1,61 @@
---
pagination:
data: collections.recipesBySlug
size: 1
alias: slugData
resolve: keys
permalink: /recipe/{{ slugData }}/
layout: base.njk
excludeFromSitemap: true
eleventyComputed:
title: "{{ collections.recipesBySlug[slugData].newest.data.title }}"
---
{% set recipeData = collections.recipesBySlug[slugData] %}
{% set recipe = recipeData.newest %}
{% if recipe %}
<article class="recipe">
<header class="recipe-header">
<h1>{{ recipe.data.title }}</h1>
</header>
<div class="recipe-content">
{{ recipe.content | 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 %}