From 0c26d352f0d4bbd32b1a4ad38dde2b55e24f240f Mon Sep 17 00:00:00 2001 From: Vinta Chen Date: Mon, 23 Mar 2026 01:11:35 +0800 Subject: [PATCH] fix(website): scope subcategory filter values to parent category Subcategories with the same name (e.g. 'Frameworks') across different top-level categories were sharing a filter value, so clicking one subcategory tag would match entries from unrelated categories. Each subcategory now stores both a display name and a scoped value ('Category > Subcategory') used for data-cats matching. The template renders the display name on tags and mobile-cat span, but uses the scoped value for filtering. Subcategory tags are also moved before category tags so the most-specific label appears first. Co-Authored-By: Claude --- website/build.py | 8 +++++--- website/templates/index.html | 18 +++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/website/build.py b/website/build.py index 821c6814..6ff46df0 100644 --- a/website/build.py +++ b/website/build.py @@ -103,8 +103,10 @@ def extract_entries( if group_name not in existing["groups"]: existing["groups"].append(group_name) subcat = entry["subcategory"] - if subcat and subcat not in existing["subcategories"]: - existing["subcategories"].append(subcat) + if subcat: + scoped = f"{cat['name']} > {subcat}" + if not any(s["value"] == scoped for s in existing["subcategories"]): + existing["subcategories"].append({"name": subcat, "value": scoped}) else: merged = { "name": entry["name"], @@ -112,7 +114,7 @@ def extract_entries( "description": entry["description"], "categories": [cat["name"]], "groups": [group_name], - "subcategories": [entry["subcategory"]] if entry["subcategory"] else [], + "subcategories": [{"name": entry["subcategory"], "value": f"{cat['name']} > {entry['subcategory']}"}] if entry["subcategory"] else [], "stars": None, "owner": None, "last_commit_at": None, diff --git a/website/templates/index.html b/website/templates/index.html index 0689d260..58967106 100644 --- a/website/templates/index.html +++ b/website/templates/index.html @@ -121,7 +121,7 @@ {% for entry in entries %} {{ entry.name }} - {{ entry.categories[0] }} + {% if entry.subcategories %}{{ entry.subcategories[0].name }}{% else %}{{ entry.categories[0] }}{% endif %} {% if entry.stars is not none %}{{ "{:,}".format(entry.stars) }}{% @@ -156,17 +156,17 @@ >{% else %}—{% endif %} - {% for cat in entry.categories %} - - {% endfor %} {% for subcat in entry.subcategories %} + {% for subcat in entry.subcategories %} + {% endfor %} {% for cat in entry.categories %} + {% endfor %}