From bd49960b65ec2f26722ef51c05926779e4661fa7 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Sun, 8 Jun 2025 17:58:48 +0300 Subject: [PATCH] treewide: set title from basename if it doesn't exist --- site.ts | 13 ++++++++++--- site/_includes/map.vto | 2 +- site/blog/2024-01-01-test.md | 3 --- site/dump/site/analytics.md | 4 ---- site/dump/site/availability.md | 4 ---- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/site.ts b/site.ts index e0afa70..54e22fa 100644 --- a/site.ts +++ b/site.ts @@ -40,7 +40,15 @@ site.data("color", color); site.add("."); -site.process([".html"], (pages) => { +site.preprocess([".html"], (pages) => + pages.forEach((page) => { + page.data.title = page.data.title ?? + page.data.basename + .replace(/-/g, " ") + .replace(/\b\w/g, (char) => char.toUpperCase()); + })); + +site.process([".html"], (pages) => pages.forEach((page) => { const document = page.document; @@ -156,8 +164,7 @@ site.process([".html"], (pages) => { footnotes.remove(); } } - }); -}); + })); site.use(extractDate()); site.use(redirects()); diff --git a/site/_includes/map.vto b/site/_includes/map.vto index d3411c1..6c007ec 100644 --- a/site/_includes/map.vto +++ b/site/_includes/map.vto @@ -1,6 +1,6 @@ {{ function process(entry, toplevel = false) }}
- {{ if entry.data.title }} + {{ if entry.data.url }}