mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-07 08:20:21 -05:00
fix(website): remove duplicate tag on group/category pages
The category template rendered a tag for `category.name` plus a tag for `entry.groups[0]`, which duplicated the group name on group pages where those values are identical (e.g. /categories/python-language/ showing "Python Language" twice). It also never rendered `entry.categories`, so group pages omitted each project's actual category. Mirror the index template's tag rendering on category, group, and subcategory pages, and mark whichever tag matches the current page URL as active. Pass `category_urls` and `current_path` to each render call so the template can match by URL.
This commit is contained in:
@@ -369,6 +369,8 @@ def build(repo_root: Path) -> None:
|
||||
entries=category_entries,
|
||||
total_categories=len(categories),
|
||||
page_kind="category",
|
||||
category_urls=category_urls,
|
||||
current_path=category_path(category),
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
@@ -390,6 +392,8 @@ def build(repo_root: Path) -> None:
|
||||
entries=group_entries,
|
||||
total_categories=len(categories),
|
||||
page_kind="group",
|
||||
category_urls=category_urls,
|
||||
current_path=group_path(group["slug"]),
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
@@ -425,6 +429,8 @@ def build(repo_root: Path) -> None:
|
||||
total_categories=len(categories),
|
||||
page_kind="subcategory",
|
||||
parent_category=category,
|
||||
category_urls=category_urls,
|
||||
current_path=subcategory_path(category["slug"], sub["slug"]),
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
@@ -117,18 +117,25 @@
|
||||
</td>
|
||||
<td class="col-cat">
|
||||
{% for subcat in entry.subcategories %}
|
||||
<button class="tag" data-value="{{ subcat.value }}" data-url="{{ subcat.url }}">
|
||||
<button class="tag{% if subcat.url == current_path %} active{% endif %}" data-value="{{ subcat.value }}" data-url="{{ subcat.url }}">
|
||||
{{ subcat.name }}
|
||||
</button>
|
||||
{% endfor %}
|
||||
<button class="tag active" data-value="{{ category.name }}" data-url="/categories/{{ category.slug }}/">
|
||||
{{ category.name }}
|
||||
</button>
|
||||
{% for cat in entry.categories %}
|
||||
<a
|
||||
class="tag{% if category_urls[cat] == current_path %} active{% endif %}"
|
||||
href="{{ category_urls[cat] }}"
|
||||
data-value="{{ cat }}"
|
||||
data-url="{{ category_urls[cat] }}"
|
||||
>{{ cat }}</a
|
||||
>
|
||||
{% endfor %}
|
||||
{% if entry.groups %}
|
||||
{% set group_url = "/categories/" ~ (entry.groups[0] | slugify) ~ "/" %}
|
||||
<button
|
||||
class="tag tag-group"
|
||||
class="tag tag-group{% if group_url == current_path %} active{% endif %}"
|
||||
data-value="{{ entry.groups[0] }}"
|
||||
data-url="/categories/{{ entry.groups[0] | slugify }}/"
|
||||
data-url="{{ group_url }}"
|
||||
>
|
||||
{{ entry.groups[0] }}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user