{#- Collect all terms. -#}
{#- We don't use `get_taxonomy` so users aren't forced to use 'tags' -#}
{% set all_terms = [] %}
{% for page in show_pages %}
    {% if page.taxonomies %}
        {% for tax_name, terms in page.taxonomies %}
            {% for term in terms %}
                {% set_global all_terms = all_terms | concat(with=term) %}
            {% endfor %}
        {% endfor %}
    {% endif %}
{% endfor %}

{#- Display unique terms -#}
{% set unique_terms = all_terms | unique | sort %}
{%- if unique_terms | length >= 2 -%}
    <ul class="filter-controls" role="group" aria-label="{{ macros_translate::translate(key='project_filters', default='Project filters', language_strings=language_strings) }}">
        <li class="taxonomy-item no-hover-padding">
            <a id="all-projects-filter" class="no-hover-padding active"
            href="{{ get_url(path="projects", lang=lang) }}"
            data-filter="all">
                {{- macros_translate::translate(key="all_projects", default="All projects", language_strings=language_strings) -}}
            </a>
        </li>
        {% for term in unique_terms %}
            <li class="taxonomy-item no-hover-padding">
                <a class="no-hover-padding"
                href="{{ get_taxonomy_url(kind="tags", name=term, lang=lang) }}"
                data-filter="{{ term | lower }}">{{ term }}</a>
            </li>
        {% endfor %}
    </ul>
    {#- Load the script -#}
    <script src="{{ get_url(path='js/filterCards.min.js', trailing_slash=false, cachebust=true) | safe }}" defer></script>
{% endif %}
