Skip to content

Commit fcdae13

Browse files
committed
Tag pages.
1 parent cdf3366 commit fcdae13

File tree

4 files changed

+70
-2
lines changed

4 files changed

+70
-2
lines changed

site/_includes/layouts/page.njk

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
layout: layouts/base.njk
33
---
44

5-
<div class="container d-flex flex-nowrap col-xl-10 col-xxl-8 px-4 py-5 mw-content">
6-
<div class="row align-items-center g-lg-6 py-5">
5+
<div class="container d-flex flex-nowrap col-xl-10 col-xxl-8 px-4 py-4 mw-content">
6+
<div class="row align-items-center g-lg-6 pb-5">
77
{{ content | safe }}
88
</div>
99
</div>

site/_includes/postslist.njk

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="px-3 width-full">
2+
{%- for post in postslist %}
3+
<div class="d-flex flex-items-center flex-column flex-nowrap mb-3">
4+
<a href="{{ post.url }}" class="d-flex align-items-center link-body-emphasis text-decoration-none">
5+
{% if post.data.title %}
6+
<span class="h6 mb-0">{{ post.data.title }}</span>
7+
{% else %}
8+
<code>{{ post.url }}</code>
9+
{% endif %}
10+
</a>
11+
<time class="text-muted" datetime="{{ post.date | htmlDateString }}">
12+
<small>{{ post.date | readableDate("LLLL yyyy") }}</small>
13+
</time>
14+
</div>
15+
{% endfor %}
16+
</div>

site/content/tag-pages.njk

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---js
2+
// <script>
3+
const pagination = {
4+
data: "collections",
5+
size: 1,
6+
alias: "tag",
7+
filter: ["all", "posts"],
8+
// addAllPagesToCollections: true,
9+
};
10+
11+
const eleventyExcludeFromCollections = true;
12+
13+
const eleventyComputed = {
14+
title: "Tagged '{{ tag }}'",
15+
permalink: function(data) {
16+
return `/tags/${this.slugify(data.tag)}/`;
17+
}
18+
};
19+
---
20+
<div class="container d-flex flex-nowrap flex-column col-xl-10 col-xxl-8 px-4 py-4 mw-content">
21+
<div class="row align-items-center g-lg-6 pb-4">
22+
<h2>{{ tag }}</h2>
23+
</div>
24+
25+
<div class="row align-items-center flex-1 g-lg-6 pb-5">
26+
{% set postslist = collections[ tag ] %}
27+
{% include "postslist.njk" %}
28+
</div>
29+
30+
<div class="row f-flex align-items-center px-1 g-lg-6 pb-5">
31+
<a class="text-primary text-decoration-none" href="tags.njk">All tags</a>
32+
</div>
33+
</div>

site/content/tags.njk

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---js
2+
const eleventyNavigation = {
3+
key: "Tags",
4+
order: 1
5+
};
6+
---
7+
<div class="container d-flex flex-nowrap col-xl-10 col-xxl-8 px-4 py-4 mw-content">
8+
<div class="row align-items-center g-lg-6 pb-5">
9+
<h2>Tags</h2>
10+
<div class="d-flex flex-nowrap flex-row fs-4">
11+
{% for tag in collections | getKeys | filterTagList %}
12+
{% set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
13+
<a href="{{ tagUrl }}" class="p-2">
14+
<span class="badge rounded-pill bg-secondary text-lowercase py-2 px-3">{{ tag }}</span>
15+
</a>
16+
{% endfor %}
17+
</div>
18+
</div>
19+
</div>

0 commit comments

Comments
 (0)