mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-07 08:20:21 -05:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user