mirror of
https://github.com/andwati/andwati.com.git
synced 2026-10-28 21:52:16 +00:00
Normalize multi-word tags to kebab-case
"subresource integrity", "task scheduler", and "conventional commits" had spaces, producing broken-looking /tags/<tag>/ 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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user