fix(tech): default Blog year category to execution year
Dateless posts silently lost their Blog:<year> 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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=<sha>}}`)
|
||||
- Category injection: `[[Category:Tech blog]]` on every page; `[[Category:Blog:<year>]]` from `date` field; `[[Category:<tag>]]` per tag entry
|
||||
- Category injection: `[[Category:Tech blog]]` on every page; `[[Category:Blog:<year>]]` from `date` field (falling back to the action's execution year); `[[Category:<tag>]]` 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:<year>` from `date` field; omitted if no date | 2026-06-10 |
|
||||
| Year category | `Category:Blog:<year>` from `date` field; falls back to the execution year if no date | 2026-06-10 |
|
||||
| Tag categories | Each tag → `[[Category:<tag>]]` 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 |
|
||||
|
||||
@@ -45,7 +45,7 @@ wiki:
|
||||
|
||||
#### `date` (ISO 8601 date)
|
||||
|
||||
Publication date in `YYYY-MM-DD` format. Drives `[[Category:Blog:<year>]]` injection. If omitted, no year category is added.
|
||||
Publication date in `YYYY-MM-DD` format. Drives `[[Category:Blog:<year>]]` 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=<source URL>|commit=<sha>}}`.
|
||||
5. Append category tags: `[[Category:Tech blog]]`; `[[Category:Blog:<year>]]` if `date` is set; `[[Category:<tag>]]` for each tag.
|
||||
5. Append category tags: `[[Category:Tech blog]]`; `[[Category:Blog:<year>]]` (from `date`, or the action's execution year if `date` is absent); `[[Category:<tag>]]` 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:<year>` from `date` field
|
||||
- `Category:Blog:<year>` from `date` field, falling back to the execution year
|
||||
- `Category:<tag>` per entry in `tags`
|
||||
- Idempotent writes
|
||||
- Manual-page protection
|
||||
|
||||
@@ -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:<year> 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"
|
||||
|
||||
Reference in New Issue
Block a user