mirror of
https://github.com/vinta/awesome-python.git
synced 2026-10-22 19:52:51 +00:00
feat(website): embed filter-to-url map in index for client routing
Adds filter_urls dict (categories, groups, subcategories) in build.py, passes filter_urls_json to the template, and injects a JSON script block before the results section in index.html. Covered by a new test that verifies all three URL types are present and correctly resolved. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e320ba7278
commit
e0e7fc9168
3 changed files with 51 additions and 0 deletions
|
|
@ -315,6 +315,15 @@ def build(repo_root: Path) -> None:
|
|||
entries = sort_entries(entries)
|
||||
category_urls = {cat["name"]: category_path(cat) for cat in categories}
|
||||
|
||||
filter_urls: dict[str, str] = {}
|
||||
for cat in categories:
|
||||
filter_urls[cat["name"]] = category_path(cat)
|
||||
for group in parsed_groups:
|
||||
filter_urls[group["name"]] = f"/categories/{group['slug']}/"
|
||||
for entry in entries:
|
||||
for sub in entry.get("subcategories", []):
|
||||
filter_urls[sub["value"]] = sub["url"]
|
||||
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(website / "templates"),
|
||||
autoescape=True,
|
||||
|
|
@ -339,6 +348,7 @@ def build(repo_root: Path) -> None:
|
|||
build_date=build_date.strftime("%B %d, %Y"),
|
||||
sponsors=sponsors,
|
||||
category_urls=category_urls,
|
||||
filter_urls_json=json.dumps(filter_urls, sort_keys=True),
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue