Modernize static site generator stack (Node 22, updated Metalsmith plugins) #2

Merged
AverageMarcus merged 5 commits from update/modernize-metalsmith-stack into master 2026-11-16 14:10:52 +00:00
Showing only changes of commit 06a50db987 - Show all commits
+8 -7
View File
@@ -164,9 +164,11 @@ function feedPlugin() {
}); });
posts.forEach((post) => { posts.forEach((post) => {
const postUrl = `https://marcusnoble.co.uk/${post.path}/`;
feed.item({ feed.item({
title: post.title, title: post.title,
url: `https://marcusnoble.co.uk/${post.path}/`, url: postUrl,
guid: postUrl,
date: post.date.toISOString(), date: post.date.toISOString(),
description: post.summary || "", description: post.summary || "",
categories: (post.tags || "").split(" ").filter(Boolean), categories: (post.tags || "").split(" ").filter(Boolean),
@@ -436,15 +438,14 @@ const ms = Metalsmith(__dirname)
const d = value; const d = value;
return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0"); return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0");
} }
return String(value).toLowerCase().replace(/\s+/g, "-").replace(slugRe, "").replace(/-+/g, "-").replace(/\./g, ""); return String(value).toLowerCase().replace(/\s+/g, "-").replace(slugRe, "").replace(/-+/g, "-");
}) })
.replace(/\/+$/, ""); .replace(/\/+$/, "");
// Add directory index // Add directory index - force index.html for permalinks without .html extension
if (path.extname(result) === "" || path.extname(result) === ".html") { // Dots in titles (like T.I.L.) confuse path.extname() so we check the actual extension
if (!path.extname(result)) { if (!result.endsWith(".html")) {
result = path.join(result, "index.html"); result = path.join(result, "index.html");
}
} }
// Post files: no prefix - URLs match production format /YYYY-MM-DD-slug/ // Post files: no prefix - URLs match production format /YYYY-MM-DD-slug/