feat: created index pages for posts and recipes

This commit is contained in:
Leyla Becker 2026-02-12 15:10:58 -06:00
parent f93207b4e3
commit 0d5bb62775
4 changed files with 110 additions and 16 deletions

View file

@ -9,10 +9,16 @@ description: Welcome to my website! I write about tech, politics, food, and hobb
</section>
{% if collections.posts.length > 0 %}
<h1>Blog Posts</h1>
<div class="section-header">
<h1>Blog Posts</h1>
{% if collections.posts.length > 3 %}
<a href="/posts/" class="view-all">view all</a>
{% endif %}
</div>
<ul class="post-list">
{% for post in collections.posts %}
{% if loop.index0 < 3 %}
<li>
<a href="{{ post.url }}" class="post-card">
<h2>{{ post.data.title }}</h2>
@ -22,32 +28,38 @@ description: Welcome to my website! I write about tech, politics, food, and hobb
{% endif %}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% set hasRecipes = false %}
{% set recipesList = [] %}
{% for slug, recipeData in collections.recipesBySlug %}
{% if recipeData.newest %}
{% set hasRecipes = true %}
{% set recipesList = recipesList.concat([{slug: slug, data: recipeData}]) %}
{% endif %}
{% endfor %}
{% if hasRecipes %}
<h1>Recipes</h1>
{% if recipesList.length > 0 %}
<div class="section-header">
<h1>Recipes</h1>
{% if recipesList.length > 3 %}
<a href="/recipes/" class="view-all">view all</a>
{% endif %}
</div>
<ul class="post-list">
{% for slug, recipeData in collections.recipesBySlug %}
{% if recipeData.newest %}
<li>
<a href="/recipe/{{ slug }}/" class="post-card">
<h2>{{ recipeData.newest.data.title }}</h2>
{% if recipeData.newest.data.description %}
<p>{{ recipeData.newest.data.description }}</p>
{% endif %}
</a>
</li>
{% endif %}
{% for recipe in recipesList %}
{% if loop.index0 < 3 %}
<li>
<a href="/recipe/{{ recipe.slug }}/" class="post-card">
<h2>{{ recipe.data.newest.data.title }}</h2>
{% if recipe.data.newest.data.description %}
<p>{{ recipe.data.newest.data.description }}</p>
{% endif %}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}