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:
2026-06-11 13:05:29 +09:00
parent bb57f319c5
commit bf96cd10e7
3 changed files with 9 additions and 8 deletions
+4 -3
View File
@@ -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"