mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-07 08:20:21 -05:00
feat(website): add subcategory_path and subcategory_public_url helpers
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -92,6 +92,14 @@ def category_public_url(category: ParsedSection) -> str:
|
||||
return f"{SITE_URL}categories/{category['slug']}/"
|
||||
|
||||
|
||||
def subcategory_path(category_slug: str, subcategory_slug: str) -> str:
|
||||
return f"/categories/{category_slug}/{subcategory_slug}/"
|
||||
|
||||
|
||||
def subcategory_public_url(category_slug: str, subcategory_slug: str) -> str:
|
||||
return f"{SITE_URL}categories/{category_slug}/{subcategory_slug}/"
|
||||
|
||||
|
||||
def write_sitemap_xml(path: Path, urls: Sequence[tuple[str, str]]) -> None:
|
||||
ET.register_namespace("", SITEMAP_NS)
|
||||
urlset = ET.Element(f"{{{SITEMAP_NS}}}urlset")
|
||||
|
||||
@@ -16,6 +16,7 @@ from build import (
|
||||
extract_github_repo,
|
||||
load_stars,
|
||||
sort_entries,
|
||||
subcategory_path,
|
||||
)
|
||||
from readme_parser import parse_readme, slugify
|
||||
|
||||
@@ -81,6 +82,14 @@ class TestSlugify:
|
||||
assert slugify(" Date and Time ") == "date-and-time"
|
||||
|
||||
|
||||
class TestSubcategoryPath:
|
||||
def test_builds_path(self):
|
||||
assert subcategory_path("web-frameworks", "synchronous") == "/categories/web-frameworks/synchronous/"
|
||||
|
||||
def test_trailing_slash(self):
|
||||
assert subcategory_path("a", "b").endswith("/")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# build (integration)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user