mirror of
https://github.com/andwati/andwati.com.git
synced 2026-10-18 09:22:53 +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:
@@ -6,7 +6,7 @@ date = 2023-10-01
|
|||||||
draft = false
|
draft = false
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
tags = [ "obsidian", "git", "sync", "windows", "cron", "task scheduler", "powershell" ]
|
tags = [ "obsidian", "git", "sync", "windows", "cron", "task-scheduler", "powershell" ]
|
||||||
|
|
||||||
+++
|
+++
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ date = 2023-01-24
|
|||||||
draft = false
|
draft = false
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
tags = [ "git", "semver", "workflow", "conventional commits" ]
|
tags = [ "git", "semver", "workflow", "conventional-commits" ]
|
||||||
|
|
||||||
+++
|
+++
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ date = 2023-04-29
|
|||||||
draft = false
|
draft = false
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
tags = [ "subresource integrity", "csp", "cors" ]
|
tags = [ "subresource-integrity", "csp", "cors" ]
|
||||||
|
|
||||||
+++
|
+++
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ function compact(obj) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeTag(tag) {
|
||||||
|
return tag.trim().toLowerCase().replace(/\s+/g, "-");
|
||||||
|
}
|
||||||
|
|
||||||
function toIsoDate(value) {
|
function toIsoDate(value) {
|
||||||
if (value instanceof Date)
|
if (value instanceof Date)
|
||||||
return new TomlDate(value.toISOString().slice(0, 10));
|
return new TomlDate(value.toISOString().slice(0, 10));
|
||||||
@@ -108,7 +112,7 @@ for (const file of files) {
|
|||||||
updated: toIsoDate(fm.updated),
|
updated: toIsoDate(fm.updated),
|
||||||
draft: fm.draft ?? false,
|
draft: fm.draft ?? false,
|
||||||
canonical_url: fm.canonical_url,
|
canonical_url: fm.canonical_url,
|
||||||
taxonomies: { tags: fm.taxonomies?.tags ?? [] },
|
taxonomies: { tags: (fm.taxonomies?.tags ?? []).map(normalizeTag) },
|
||||||
extra: {
|
extra: {
|
||||||
series: fm.extra?.series,
|
series: fm.extra?.series,
|
||||||
series_index: fm.extra?.series_index,
|
series_index: fm.extra?.series_index,
|
||||||
|
|||||||
Reference in New Issue
Block a user