feat(website): show parent category breadcrumb on subcategory pages

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-05-03 00:27:22 +08:00
parent 6bc9d83480
commit 03702231af
2 changed files with 33 additions and 0 deletions

View File

@@ -24,6 +24,11 @@
</nav>
<div class="category-hero-copy">
{% if page_kind == "subcategory" and parent_category %}
<p class="category-breadcrumb">
<a href="/categories/{{ parent_category.slug }}/">{{ parent_category.name }}</a>
</p>
{% endif %}
<h1>{{ category.name }}</h1>
{% if category.description_html %}
<p class="category-subtitle">{{ category.description_html | safe }}</p>

View File

@@ -577,6 +577,34 @@ class TestBuild:
assert "fastapi" in async_
assert "django" not in async_
def test_subcategory_page_shows_breadcrumb(self, tmp_path):
readme = textwrap.dedent("""\
# T
---
**Web**
## Web Frameworks
- Synchronous
- [django](https://example.com/django) - Sync.
# Contributing
Done.
""")
self._copy_real_templates(tmp_path)
(tmp_path / "README.md").write_text(readme, encoding="utf-8")
build(tmp_path)
site = tmp_path / "website" / "output"
sync = (site / "categories" / "web-frameworks" / "synchronous" / "index.html").read_text(encoding="utf-8")
assert 'href="/categories/web-frameworks/"' in sync
assert "Web Frameworks" in sync
assert "<h1>Synchronous</h1>" in sync
def test_build_creates_group_pages(self, tmp_path):
readme = textwrap.dedent("""\
# T