From 3d4b2fcd64789e4a81a3fdfa75b7d788270c6020 Mon Sep 17 00:00:00 2001 From: andwati Date: Mon, 31 Aug 2026 07:47:54 +0300 Subject: [PATCH] Normalize multi-word tags to kebab-case "subresource integrity", "task scheduler", and "conventional commits" had spaces, producing broken-looking /tags// URLs. Also fixes a silent bug: site.config.ts's tagDescriptions already keyed "subresource-integrity" with a hyphen, so the per-tag description never actually matched the un-normalized tag. Added normalizeTag() to migrate-posts-to-writings.mjs so re-running the migration script doesn't reintroduce the spaces from the untouched content/posts/ originals. --- content/writings/obsidian-sync/index.md | 2 +- .../semantic-version-and-conventional-commits/index.md | 2 +- content/writings/subresource-integrity/index.md | 2 +- scripts/migrate-posts-to-writings.mjs | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/content/writings/obsidian-sync/index.md b/content/writings/obsidian-sync/index.md index 008ac3c..fc8067c 100644 --- a/content/writings/obsidian-sync/index.md +++ b/content/writings/obsidian-sync/index.md @@ -6,7 +6,7 @@ date = 2023-10-01 draft = false [taxonomies] -tags = [ "obsidian", "git", "sync", "windows", "cron", "task scheduler", "powershell" ] +tags = [ "obsidian", "git", "sync", "windows", "cron", "task-scheduler", "powershell" ] +++ diff --git a/content/writings/semantic-version-and-conventional-commits/index.md b/content/writings/semantic-version-and-conventional-commits/index.md index 6e65de6..660b086 100644 --- a/content/writings/semantic-version-and-conventional-commits/index.md +++ b/content/writings/semantic-version-and-conventional-commits/index.md @@ -6,7 +6,7 @@ date = 2023-01-24 draft = false [taxonomies] -tags = [ "git", "semver", "workflow", "conventional commits" ] +tags = [ "git", "semver", "workflow", "conventional-commits" ] +++ diff --git a/content/writings/subresource-integrity/index.md b/content/writings/subresource-integrity/index.md index 1ee4bb9..675d5de 100644 --- a/content/writings/subresource-integrity/index.md +++ b/content/writings/subresource-integrity/index.md @@ -6,7 +6,7 @@ date = 2023-04-29 draft = false [taxonomies] -tags = [ "subresource integrity", "csp", "cors" ] +tags = [ "subresource-integrity", "csp", "cors" ] +++ diff --git a/scripts/migrate-posts-to-writings.mjs b/scripts/migrate-posts-to-writings.mjs index ce9a4aa..e96a1cc 100644 --- a/scripts/migrate-posts-to-writings.mjs +++ b/scripts/migrate-posts-to-writings.mjs @@ -50,6 +50,10 @@ function compact(obj) { return out; } +function normalizeTag(tag) { + return tag.trim().toLowerCase().replace(/\s+/g, "-"); +} + function toIsoDate(value) { if (value instanceof Date) return new TomlDate(value.toISOString().slice(0, 10)); @@ -108,7 +112,7 @@ for (const file of files) { updated: toIsoDate(fm.updated), draft: fm.draft ?? false, canonical_url: fm.canonical_url, - taxonomies: { tags: fm.taxonomies?.tags ?? [] }, + taxonomies: { tags: (fm.taxonomies?.tags ?? []).map(normalizeTag) }, extra: { series: fm.extra?.series, series_index: fm.extra?.series_index,