mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-13 16:37:59 +00: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:
parent
eeecacc3bd
commit
6bc9d83480
1 changed files with 2 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue