fix: slugified URLs for tag links

This commit is contained in:
madrilene 2025-06-02 10:08:57 +02:00
parent b8eaeadecb
commit 33f6ee279e
5 changed files with 7 additions and 7 deletions

View file

@ -16,7 +16,7 @@ export function getLinkActiveState(itemUrl, pageUrl) {
} }
if (itemUrl.length > 1 && pageUrl.startsWith(itemUrl.replace('/page-0/', ''))) { if (itemUrl.length > 1 && pageUrl.startsWith(itemUrl.replace('/page-0/', ''))) {
response += ' data-state="active"'; response += ' aria-current="page" data-state="active"';
} }
} }

View file

@ -1,7 +1,7 @@
{% if tags.size > 1 %} {% if tags.size > 1 %}
<div class="my-s-m cluster"> <div class="my-s-m cluster">
{% for tag in tags %} {% for tag in tags %}
<a href="/tags/{{ tag }}/"> {{ tag }} </a> <a href="/tags/{{ tag | slugify }}/"> {{ tag }} </a>
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}

View file

@ -25,7 +25,7 @@ schema: BlogPosting
%} %}
<!-- tags --> <!-- tags -->
{% for tag in tags %}{% if tag != "posts" %} {% for tag in tags %}{% if tag != "posts" %}
<a class="button" href="/tags/{{ tag }}/" data-small-button> {{ tag }} </a> <a class="button" href="/tags/{{ tag | slugify }}/" data-small-button> {{ tag }} </a>
{% endif %}{% endfor %} {% endif %}{% endfor %}
{% endif %} {% endif %}
</p> </p>

View file

@ -4,7 +4,7 @@ pagination:
data: collections.tagList data: collections.tagList
size: 1 size: 1
alias: tag alias: tag
permalink: /tags/{{ tag }}/ permalink: /tags/{{ tag | slugify }}/
eleventyComputed: eleventyComputed:
title: '{{ meta.blog.tagSingle }}: {{ tag }}' title: '{{ meta.blog.tagSingle }}: {{ tag }}'
--- ---
@ -23,10 +23,10 @@ eleventyComputed:
{% for tag in collections.tagList %} {% for tag in collections.tagList %}
<li> <li>
<a <a
href="/tags/{{ tag }}/" href="/tags/{{ tag | slugify }}/"
class="button" class="button"
{{ {{
helpers.getLinkActiveState('/tags/' + tag, helpers.getLinkActiveState('/tags/' + tag | slugify + '/',
page.url) page.url)
| |
safe safe

View file

@ -7,7 +7,7 @@ eleventyComputed:
<div class="taglist | mt-s-m cluster"> <div class="taglist | mt-s-m cluster">
{% for tag in collections.tagList %} {% for tag in collections.tagList %}
<a href="/tags/{{ tag }}/" class="button"> {{ tag }} </a> <a href="/tags/{{ tag | slugify }}/" class="button"> {{ tag }} </a>
{% endfor %} {% endfor %}
</div> </div>