Compare commits

...
Author SHA1 Message Date
Marcus Noble 25186c75b9 fix: RSS feed description contains only article content, not full page
Extract just the <article> element (title + body) for feed descriptions,
removing header, navigation, share buttons, and footer.
2026-11-16 15:29:02 +00:00
Marcus Noble 334fa146c7 fix: RSS feed includes full post content instead of summary only
- Extract body content from rendered HTML for feed descriptions
- Feed readers will now see full post content, not just front-matter summary
2026-11-16 15:26:01 +00:00
Marcus Noble 06a50db987 fix: add feed GUIDs and match production URL format
- Add <guid> elements to RSS feed (matching <link> URLs)
- Preserve dots in slugs (t.i.l. instead of til) to match production
- URLs now match production format: /YYYY-MM-DD-title-slug/
  No /posts/ prefix, with dots preserved for T.I.L. posts
- This ensures feed readers won't mark posts as new
2026-11-16 13:35:16 +00:00
Marcus Noble 63a171aefd fix: match production URL format and fix OG URL
- Use front-matter title for post slug (not filename)
- Remove /posts/ prefix from URLs to match production
- Remove /pages/ prefix from page URLs to match production
- Fix OG URL on index page (no longer shows .html extension)
- Remove dots from slugs (fixes T.I.L. posts being files not dirs)
- Collapse consecutive dashes in slugs
- Remove / from slug character class (prevents URL paths in slugs)
- Skip index.html in permalink plugin (already has correct path from pagination)

Production URL format: /YYYY-MM-DD-full-title-slug/
2026-11-16 12:15:05 +00:00
Marcus Noble b21390b1a4 fix: use @metalsmith/collections v2 sort API for descending post order
The v2 API uses sort: 'date:desc' instead of sortBy: 'date' + reverse:
true. This ensures posts display newest-first on the index page.
2026-11-16 11:10:33 +00:00
Marcus Noble b547cd3137 fix: copy static CSS files (pico.min.css, zenburn.css) to build
The .ignore(['css']) pattern was preventing all CSS files in src/css/
from being copied to the build directory. Only SCSS source files should
be ignored - pre-compiled CSS dependencies like pico.min.css and
zenburn.css need to be served by the static file server.
2026-11-16 11:04:31 +00:00
2 changed files with 37 additions and 37 deletions

No files matched your search

+34 -23
View File
@@ -164,11 +164,26 @@ function feedPlugin() {
}); });
posts.forEach((post) => { posts.forEach((post) => {
const postUrl = `https://marcusnoble.co.uk/${post.path}/`;
// Find the rendered HTML content for this post
// post.path is the permalink path (e.g., 2026-03-17-kubecon-...), files use /index.html
const contentKey = post.path + '/index.html';
let renderedContent = "";
if (files[contentKey]) {
const fullHtml = files[contentKey].contents.toString();
// Extract just the post content (not header/footer/navigation)
// Match the article element which contains the actual post content
const articleMatch = fullHtml.match(/<article[^>]*>([\s\S]*?)<\/article>/i);
renderedContent = articleMatch ? articleMatch[1].trim() : fullHtml;
}
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: renderedContent || post.summary || "",
categories: (post.tags || "").split(" ").filter(Boolean), categories: (post.tags || "").split(" ").filter(Boolean),
}); });
}); });
@@ -300,7 +315,7 @@ function handlebarsPreprocessor() {
compileSass(__dirname, path.join(__dirname, "build")); compileSass(__dirname, path.join(__dirname, "build"));
const ms = Metalsmith(__dirname) const ms = Metalsmith(__dirname)
.ignore(['css']) // Don't copy CSS source files to build .ignore(['**/*.scss']) // Don't copy SCSS source files to build
.clean(false) // Don't clean build directory (pre-build SCSS compilation outputs preserved) .clean(false) // Don't clean build directory (pre-build SCSS compilation outputs preserved)
.source("src") .source("src")
.use( .use(
@@ -324,13 +339,11 @@ const ms = Metalsmith(__dirname)
collections({ collections({
posts: { posts: {
pattern: "posts/*.{md,markdown}", pattern: "posts/*.{md,markdown}",
sortBy: "date", sort: "date:desc",
reverse: true,
}, },
drafts: { drafts: {
pattern: "drafts/*.{md,markdown}", pattern: "drafts/*.{md,markdown}",
sortBy: "date", sort: "date:desc",
reverse: true,
}, },
projects: { projects: {
pattern: "projects/*", pattern: "projects/*",
@@ -379,7 +392,7 @@ const ms = Metalsmith(__dirname)
.use(function (files, metalsmith, done) { .use(function (files, metalsmith, done) {
// Pre-compute paths for layouts rendering // Pre-compute paths for layouts rendering
// This mirrors the permalinks logic but doesn't rename files // This mirrors the permalinks logic but doesn't rename files
const slugRe = /[<>:"'\|?*]|[^\w\s$_+~.()!\-@\/]+/g; const slugRe = /[<>:"'\|?*]|[^\w\s$_+~.()!\-@]+/g;
const linksets = [ const linksets = [
{ match: { collection: "pages" }, pattern: ":title" }, { match: { collection: "pages" }, pattern: ":title" },
{ match: { collection: "drafts" }, pattern: "drafts/:title" }, { match: { collection: "drafts" }, pattern: "drafts/:title" },
@@ -398,6 +411,12 @@ const ms = Metalsmith(__dirname)
// Skip layout files (layout matches filename) // Skip layout files (layout matches filename)
const baseName = path.basename(file, ".html"); const baseName = path.basename(file, ".html");
// Don't skip index.html - it already has permalink from pagination
if (file === "index.html") {
// Set path for index page (root URL)
data.path = "";
continue;
}
if (data.layout === baseName || data.layout === `${baseName}.html`) continue; if (data.layout === baseName || data.layout === `${baseName}.html`) continue;
// Determine linkset // Determine linkset
@@ -428,30 +447,22 @@ const ms = Metalsmith(__dirname)
const d = data._filenameDate; const d = data._filenameDate;
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");
} }
if (key === "title" && data._filenameTitle) {
return data._filenameTitle.replace(/\s+/g, "-").replace(slugRe, "");
}
if (value instanceof Date) { if (value instanceof Date) {
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, ""); 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");
}
} }
// Prepend source directory prefix // Post files: no prefix - URLs match production format /YYYY-MM-DD-slug/
let sourcePrefix = ""; data.permalink = result;
if (file.startsWith("posts/")) sourcePrefix = "posts/";
else if (file.startsWith("pages/")) sourcePrefix = "pages/";
data.permalink = sourcePrefix + result;
// Set path for templates (permalink without index.html) // Set path for templates (permalink without index.html)
if (data.permalink.endsWith("/index.html")) { if (data.permalink.endsWith("/index.html")) {
+3 -14
View File
@@ -69,14 +69,10 @@ function permalinks(options) {
if (key === 'date' && data._filenameDate) { if (key === 'date' && data._filenameDate) {
return formatDate(data._filenameDate); return formatDate(data._filenameDate);
} }
// For title in permalink, use _filenameTitle if available (to match source filenames)
if (key === 'title' && data._filenameTitle) {
return slugify(data._filenameTitle);
}
if (value instanceof Date) { if (value instanceof Date) {
return formatDate(value); return formatDate(value);
} }
return slugify(value.toString()); return slugify(value.toString()).replace(/-+/, "-");
}); });
} }
@@ -131,14 +127,8 @@ function permalinks(options) {
continue; continue;
} }
// For posts: preserve the "posts/" prefix
// For other files: use the pattern as-is
let sourcePrefix = ""; let sourcePrefix = "";
if (file.startsWith("posts/")) {
sourcePrefix = "posts/";
} else if (file.startsWith("pages/")) {
sourcePrefix = "pages/";
}
// Replace pattern placeholders // Replace pattern placeholders
let result = replacePattern(pattern, data); let result = replacePattern(pattern, data);
@@ -155,8 +145,7 @@ function permalinks(options) {
} }
} }
// Prepend source directory prefix data.permalink = result;
data.permalink = sourcePrefix + result;
// Set path metadata for templates (permalink without index.html) // Set path metadata for templates (permalink without index.html)
if (data.permalink.endsWith("/index.html")) { if (data.permalink.endsWith("/index.html")) {