fix(website): key dedup by (url, name) to allow same-url different-name entries

Previously, two entries sharing the same URL but different names would be
collapsed into one. Using a composite (url, name) key preserves distinct
entries while still merging true duplicates.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-03-22 02:08:42 +08:00
parent bfaa207ef3
commit 8e7b881659
+5 -4
View File
@@ -106,14 +106,15 @@ def extract_entries(
for cat in group["categories"]: for cat in group["categories"]:
cat_to_group[cat["name"]] = group["name"] cat_to_group[cat["name"]] = group["name"]
seen: dict[str, dict] = {} # url -> entry seen: dict[tuple[str, str], dict] = {} # (url, name) -> entry
entries: list[dict] = [] entries: list[dict] = []
for cat in categories: for cat in categories:
group_name = cat_to_group.get(cat["name"], "Other") group_name = cat_to_group.get(cat["name"], "Other")
for entry in cat["entries"]: for entry in cat["entries"]:
url = entry["url"] url = entry["url"]
if url in seen: key = (url, entry["name"])
existing = seen[url] if key in seen:
existing = seen[key]
if cat["name"] not in existing["categories"]: if cat["name"] not in existing["categories"]:
existing["categories"].append(cat["name"]) existing["categories"].append(cat["name"])
if group_name not in existing["groups"]: if group_name not in existing["groups"]:
@@ -131,7 +132,7 @@ def extract_entries(
"source_type": detect_source_type(url), "source_type": detect_source_type(url),
"also_see": entry["also_see"], "also_see": entry["also_see"],
} }
seen[url] = merged seen[key] = merged
entries.append(merged) entries.append(merged)
return entries return entries