From 6bc9d834802781b89986e0d2d0f2c63bcfcf8fca Mon Sep 17 00:00:00 2001 From: Vinta Chen Date: Sun, 3 May 2026 00:26:12 +0800 Subject: [PATCH] refactor(website): match subcategory by URL prefix instead of name split Use the precomputed sub["url"] to identify which subcategories belong to a category. Avoids parsing the "Cat > Sub" value string, which would silently misfire if a category name ever contained " > ". Co-Authored-By: Claude Opus 4.7 (1M context) --- website/build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/build.py b/website/build.py index 07f26cb9..3b74f533 100644 --- a/website/build.py +++ b/website/build.py @@ -383,9 +383,10 @@ def build(repo_root: Path) -> None: seen_subcats: set[tuple[str, str]] = set() for category in categories: + cat_url_prefix = f"/categories/{category['slug']}/" for entry in entries: for sub in entry.get("subcategories", []): - if sub["value"].split(" > ", 1)[0] != category["name"]: + if not sub["url"].startswith(cat_url_prefix): continue key = (category["slug"], sub["slug"]) if key in seen_subcats: