Skip to content

Commit 84f566e

Browse files
committed
chore: update tag archive
1 parent e1cb084 commit 84f566e

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

content/tags/music/style/worship.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
archived: true
23
---
34

45
Music to praise and honour the one true God.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: ESP32
3+
archived: true
34
---
45

56
A series of low-cost, low-power system-on-a-chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth. Reliable.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: IoT
3+
archived: true
34
---
45

56
The Internet of Things (IoT) describes physical objects with sensors, processing ability, software and other technologies that connect and exchange data with other devices and systems over the internet or other communications networks.

content/tags/tags.11tydata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
sortByLatest: true,
1212
date: '2022-08-01',
1313
eleventyComputed: {
14-
permalink: data => `/tags/${data.page.fileSlug}/index.html`,
14+
permalink: data => data.archived ? false : (data.permalink ?? `/tags/${data.page.fileSlug}/index.html`),
1515
title: data => data.title || toTitleCase(data.page.fileSlug),
1616
tag: data => data.page.fileSlug,
1717

eleventy/filters.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,19 @@ export default function (eleventyConfig) {
246246
const db = new Date(b);
247247
return da > db ? da : db;
248248
});
249+
250+
eleventyConfig.addNunjucksGlobal('checkNonEmptyTag', (xs, tag, archived) => {
251+
if (typeof xs.length !== 'number') {
252+
throw new Error(`expected array but got ${xs.length}`);
253+
}
254+
if (!archived) {
255+
if (xs.length === 0) {
256+
console.warn(`Detected tag with no post: ${tag}. Consider adding \`archive: true\` to the frontmatter.`);
257+
}
258+
} else {
259+
if (xs.length > 0) {
260+
console.warn(`Detected tag with posts, and tag is archived. Consider removing the tag from the posts:\n${xs.map(x => x.page.filePathStem).join('\n')}.`)
261+
}
262+
}
263+
});
249264
};

partials/_includes/layouts/page-tag.njk

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ layout: layouts/page-default
33
logo: tag
44
---
55

6+
{% set _xxx = checkNonEmptyTag(collections[tag], tag, archived) %}
7+
68
{# See Note [with context]. #}
79
{% from "post/preview.html" import render_post_preview with context %}
810
{% from "sidebars/sidebar-utils.html" import tags_sidebar with context %}
@@ -11,8 +13,10 @@ logo: tag
1113

1214
<div class="page-content-container row gx-lg-5">
1315
<div class="col-lg-4">
14-
{% set groups = [tag] | getRelatedTags(collections.tags, collections.tagcount) %}
15-
{{ tags_sidebar("Related Tags", groups) }}
16+
{% if not archived %} {# Avoid calling getRelatedTags on archived tags... #}
17+
{% set groups = [tag] | getRelatedTags(collections.tags, collections.tagcount) %}
18+
{{ tags_sidebar("Related Tags", groups) }}
19+
{% endif %}
1620
</div>
1721

1822
<div class="col-lg-8">

0 commit comments

Comments
 (0)