From bf96cd10e757a5f2dc7ad224c39df4c0816fb4c6 Mon Sep 17 00:00:00 2001 From: Mikkeli Matlock Date: Thu, 11 Jun 2026 13:05:29 +0900 Subject: [PATCH] fix(tech): default Blog year category to execution year Dateless posts silently lost their Blog: category. build_wikitext now falls back to datetime.now().year when no date is declared, so every published post lands in a year category. Docs corrected accordingly. Co-Authored-By: Claude Opus 4.8 --- pipelines/tech/README.md | 4 ++-- pipelines/tech/SCHEMA.md | 6 +++--- pipelines/tech/publish.py | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pipelines/tech/README.md b/pipelines/tech/README.md index 2050bcd..ecc7fc0 100644 --- a/pipelines/tech/README.md +++ b/pipelines/tech/README.md @@ -10,7 +10,7 @@ Publishes tech blog posts from `mikkeli/tech-blogs` to `https://wiki.novoyuuparo - YAML frontmatter parsing per [SCHEMA.md](SCHEMA.md) - Pandoc-based markdown → wikitext body rendering (h1 elements preserved) - Auto-generated banner (`{{Auto-generated|source=...|commit=}}`) -- Category injection: `[[Category:Tech blog]]` on every page; `[[Category:Blog:]]` from `date` field; `[[Category:]]` per tag entry +- Category injection: `[[Category:Tech blog]]` on every page; `[[Category:Blog:]]` from `date` field (falling back to the action's execution year); `[[Category:]]` per tag entry - No title prefix — pages live at their bare title - MediaWiki bot API write with idempotency — no-op if wiki content matches generated output - Files without `wiki.publish: true` silently skipped @@ -65,7 +65,7 @@ Shared code lives in `lib/wiki.py` (repo root). |---|---|---| | No title prefix | Tech posts live at bare titles — no namespace needed | 2026-06-10 | | Fixed category | Every post gets `Category:Tech blog` | 2026-06-10 | -| Year category | `Category:Blog:` from `date` field; omitted if no date | 2026-06-10 | +| Year category | `Category:Blog:` from `date` field; falls back to the execution year if no date | 2026-06-10 | | Tag categories | Each tag → `[[Category:]]` with no prefix | 2026-06-10 | | WIP exclusion | None — `wiki.publish: false` is the only gate | 2026-06-10 | | Publish mode | Always `--all` | 2026-06-10 | diff --git a/pipelines/tech/SCHEMA.md b/pipelines/tech/SCHEMA.md index e5dc9c4..9747857 100644 --- a/pipelines/tech/SCHEMA.md +++ b/pipelines/tech/SCHEMA.md @@ -45,7 +45,7 @@ wiki: #### `date` (ISO 8601 date) -Publication date in `YYYY-MM-DD` format. Drives `[[Category:Blog:]]` injection. If omitted, no year category is added. +Publication date in `YYYY-MM-DD` format. Drives `[[Category:Blog:]]` injection. If omitted, the year falls back to the time the publish action runs. #### `tags` (list of strings) @@ -69,7 +69,7 @@ For each `.md` with `wiki.publish: true`: 1. Parse and validate frontmatter. 2. Pipe the body through `pandoc -f markdown -t mediawiki`. 4. Prepend the auto-generated banner: `{{Auto-generated|source=|commit=}}`. -5. Append category tags: `[[Category:Tech blog]]`; `[[Category:Blog:]]` if `date` is set; `[[Category:]]` for each tag. +5. Append category tags: `[[Category:Tech blog]]`; `[[Category:Blog:]]` (from `date`, or the action's execution year if `date` is absent); `[[Category:]]` for each tag. 6. Read the current wiki page content; if identical, skip the write (idempotency). 7. If the page exists without `{{Auto-generated`, skip with a warning (manual page protection). 8. Otherwise, write with an edit summary referencing the source commit. @@ -80,7 +80,7 @@ For each `.md` with `wiki.publish: true`: - Pandoc-based markdown → wikitext rendering (h1 elements preserved) - Banner template injection - `Category:Tech blog` on every published page -- `Category:Blog:` from `date` field +- `Category:Blog:` from `date` field, falling back to the execution year - `Category:` per entry in `tags` - Idempotent writes - Manual-page protection diff --git a/pipelines/tech/publish.py b/pipelines/tech/publish.py index 97da4c3..6ba6091 100644 --- a/pipelines/tech/publish.py +++ b/pipelines/tech/publish.py @@ -41,9 +41,10 @@ def build_wikitext(fm: dict, body_wikitext: str, source_url: str, source_ref: st banner = f"{{{{Auto-generated|source={source_url}|commit={source_ref}}}}}" cat_parts = ["[[Category:Tech blog]]"] date_val = fm.get("date") - if date_val: - year = str(date_val)[:4] - cat_parts.append(f"[[Category:Blog:{year}]]") + # Fall back to the action's execution year when no date is declared, so + # every post still lands in a Blog: category. + year = str(date_val)[:4] if date_val else str(datetime.now().year) + cat_parts.append(f"[[Category:Blog:{year}]]") for tag in (fm.get("tags") or []): cat_parts.append(f"[[Category:{tag}]]") categories = "\n".join(cat_parts) + "\n"