feat: created index pages for posts and recipes
This commit is contained in:
parent
f93207b4e3
commit
0d5bb62775
4 changed files with 110 additions and 16 deletions
|
|
@ -64,6 +64,28 @@ a {
|
||||||
color: var(--secondary-color);
|
color: var(--secondary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Section header with view all link */
|
||||||
|
.section-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-header h1 {
|
||||||
|
margin: 1.5rem 0 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-all {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--secondary-color);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-all:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
/* Blog post list */
|
/* Blog post list */
|
||||||
.post-list {
|
.post-list {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
|
||||||
44
index.njk
44
index.njk
|
|
@ -9,10 +9,16 @@ description: Welcome to my website! I write about tech, politics, food, and hobb
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% if collections.posts.length > 0 %}
|
{% 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">
|
<ul class="post-list">
|
||||||
{% for post in collections.posts %}
|
{% for post in collections.posts %}
|
||||||
|
{% if loop.index0 < 3 %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ post.url }}" class="post-card">
|
<a href="{{ post.url }}" class="post-card">
|
||||||
<h2>{{ post.data.title }}</h2>
|
<h2>{{ post.data.title }}</h2>
|
||||||
|
|
@ -22,32 +28,38 @@ description: Welcome to my website! I write about tech, politics, food, and hobb
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% set hasRecipes = false %}
|
{% set recipesList = [] %}
|
||||||
{% for slug, recipeData in collections.recipesBySlug %}
|
{% for slug, recipeData in collections.recipesBySlug %}
|
||||||
{% if recipeData.newest %}
|
{% if recipeData.newest %}
|
||||||
{% set hasRecipes = true %}
|
{% set recipesList = recipesList.concat([{slug: slug, data: recipeData}]) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if hasRecipes %}
|
{% if recipesList.length > 0 %}
|
||||||
<h1>Recipes</h1>
|
<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">
|
<ul class="post-list">
|
||||||
{% for slug, recipeData in collections.recipesBySlug %}
|
{% for recipe in recipesList %}
|
||||||
{% if recipeData.newest %}
|
{% if loop.index0 < 3 %}
|
||||||
<li>
|
<li>
|
||||||
<a href="/recipe/{{ slug }}/" class="post-card">
|
<a href="/recipe/{{ recipe.slug }}/" class="post-card">
|
||||||
<h2>{{ recipeData.newest.data.title }}</h2>
|
<h2>{{ recipe.data.newest.data.title }}</h2>
|
||||||
{% if recipeData.newest.data.description %}
|
{% if recipe.data.newest.data.description %}
|
||||||
<p>{{ recipeData.newest.data.description }}</p>
|
<p>{{ recipe.data.newest.data.description }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
26
posts-index.njk
Normal file
26
posts-index.njk
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
layout: base.njk
|
||||||
|
title: All Blog Posts
|
||||||
|
description: All blog posts on Volpe.
|
||||||
|
permalink: /posts/
|
||||||
|
---
|
||||||
|
|
||||||
|
<h1>Blog Posts</h1>
|
||||||
|
|
||||||
|
{% if collections.posts.length > 0 %}
|
||||||
|
<ul class="post-list">
|
||||||
|
{% for post in collections.posts %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ post.url }}" class="post-card">
|
||||||
|
<h2>{{ post.data.title }}</h2>
|
||||||
|
<time datetime="{{ post.data.createdAt | dateTimeFormat }}">{{ post.data.createdAt | dateTimeFormat }}</time>
|
||||||
|
{% if post.data.description %}
|
||||||
|
<p>{{ post.data.description }}</p>
|
||||||
|
{% endif %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No blog posts yet.</p>
|
||||||
|
{% endif %}
|
||||||
34
recipes-index.njk
Normal file
34
recipes-index.njk
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
---
|
||||||
|
layout: base.njk
|
||||||
|
title: All Recipes
|
||||||
|
description: All recipes on Volpe.
|
||||||
|
permalink: /recipes/
|
||||||
|
---
|
||||||
|
|
||||||
|
<h1>Recipes</h1>
|
||||||
|
|
||||||
|
{% set hasRecipes = false %}
|
||||||
|
{% for slug, recipeData in collections.recipesBySlug %}
|
||||||
|
{% if recipeData.newest %}
|
||||||
|
{% set hasRecipes = true %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if hasRecipes %}
|
||||||
|
<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 %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No recipes yet.</p>
|
||||||
|
{% endif %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue