mirror of
https://github.com/vinta/awesome-python.git
synced 2026-10-06 17:05:16 +08:00
feat: link section use-case headings to their subcategory pages
With tags now pointing at section anchors instead of filtering in place, subcategory pages (74 clicks and 19.7K impressions in the last 3 months) had no other internal links pointing to them. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -276,7 +276,8 @@ def group_section_entries(section: ParsedSection, entries_by_key: dict[tuple[str
|
||||
groups: dict[str, EntryGroup] = {}
|
||||
for parsed in section["entries"]:
|
||||
name = parsed["subcategory"]
|
||||
group = groups.setdefault(name, EntryGroup(name=name, slug=slugify(name) if name else "", url="", entries=[]))
|
||||
slug = slugify(name) if name else ""
|
||||
group = groups.setdefault(name, EntryGroup(name=name, slug=slug, url=subcategory_path(section["slug"], slug) if name else "", entries=[]))
|
||||
group["entries"].append(entries_by_key[(parsed["url"], parsed["name"])])
|
||||
return list(groups.values())
|
||||
|
||||
|
||||
@@ -990,6 +990,7 @@ class TestBuild:
|
||||
positions = [html.index(marker) for marker in ('<h2 id="small">', ">w2</a", ">w1</a", '<h2 id="large">', ">w3</a")]
|
||||
assert positions == sorted(positions)
|
||||
assert '<a class="jump-link" href="#small">Small</a>' in html
|
||||
assert '<a href="/categories/widgets/small/">Small</a>' in html
|
||||
assert '<tr class="desc-row">' in html
|
||||
|
||||
subcategory_html = (site / "widgets" / "small" / "index.html").read_text(encoding="utf-8")
|
||||
|
||||
Reference in New Issue
Block a user