fix: stop repeating Python in group page titles

Group pages whose names start with "Python" got titles like "Python Python Language Libraries" in the title, og:title, and JSON-LD name.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-10-02 14:45:44 +08:00
co-authored by Claude
parent 5d1c881304
commit 775caf6a1e
2 changed files with 6 additions and 1 deletions
+2 -1
View File
@@ -233,7 +233,8 @@ def category_meta_title(name: str, parent_name: str | None = None) -> str:
return f"{name} - Awesome Python"
# Names ending in one of these nouns already say what the entries are.
noun = "" if name.rsplit(" ", 1)[-1] in PLURAL_NOUNS else " Libraries"
title = f"Python {name}{noun} - Awesome Python"
prefix = "" if name.startswith("Python ") else "Python "
title = f"{prefix}{name}{noun} - Awesome Python"
if len(title) <= 60:
return title
return f"{name} - Awesome Python"
+4
View File
@@ -14,6 +14,7 @@ from build import (
TemplateEntry,
annotate_entries_with_stats,
build,
category_meta_title,
detect_source_type,
extract_entries,
extract_github_repo,
@@ -784,6 +785,9 @@ class TestBuild:
assert graph["CollectionPage"]["name"] == "Python Web Frameworks"
assert "<title>Python Web APIs Libraries - Awesome Python</title>" in apis_html
def test_category_title_does_not_repeat_leading_python(self):
assert category_meta_title("Python Language") == "Python Language Libraries - Awesome Python"
def test_build_creates_subcategory_pages(self, tmp_path):
readme = textwrap.dedent("""\
# T