Add pages for tags and link to them

This commit is contained in:
Neil Brommer 2023-07-09 22:28:59 -07:00
parent 19696fad1d
commit ed004bfd8a
6 changed files with 45 additions and 21 deletions

View file

@ -7,19 +7,5 @@ eleventyNavigation:
order: 1
---
{% if collections.posts | filterDrafts | IsNotPage(page.url) | length %}
{% for post in collections.posts | filterDrafts | IsNotPage(page.url) | reverse %}
<section>
<h2><a href={{ post.url }}>{{ post.data.title }}</a></h2>
<div>
<svg class="icon">
<use href="/images/feather-sprite.svg#clock" />
</svg>
{{ post.date.toLocaleDateString("en-US") }}
</div>
<p>{{ post.data.description }}</p>
</section>
{% endfor %}
{% else %}
<p>No posts</p>
{% endif %}
{% set postsList = collections.posts | IsNotPage(page.url) %}
{% include "posts-list.njk" %}

14
src/posts/tags.njk Normal file
View file

@ -0,0 +1,14 @@
---
layout: layouts/layout.njk
pagination:
data: collections
size: 1
alias: tag
filter: [ all, post, posts, MainPage ]
eleventyComputed:
title: Posts Tagged "{{ tag }}"
permalink: /posts/tags/{{ tag | slugify }}
---
{% set postsList = collections[tag] %}
{% include "posts-list.njk" %}