{% extends 'partials/base.html.twig' %}
{% block content %}
{% set catlist = taxonomy.taxonomy["category"]|keys %}
{% if grav.theme.config.params.articles.blacklist is defined %}
    {% set blist = grav.theme.config.params.articles.blacklist %}
    {% set tmplst = [] %}
    {% for cat in catlist %}
        {% if cat not in blist %}
            {% set tmplst = tmplst|merge([cat]) %}
        {% endif %}
    {% endfor %}
    {% set catlist = tmplst %}
{% endif %}
    {% set taxname = uri.query('name') %}
    {% set taxval = uri.query('val') %}
    {% if taxname %}
        {% if taxname == 'category' %}
            {% if taxval %}
                
                    {{ 'CATEGORY'|t }} {{ taxval }}
                    {% include 'partials/topiclist.html.twig' with {'articles': taxonomy.findTaxonomy({(taxname): taxval})} %}
                
            {% else %}
                
                    Categories
                    
                    {% for cat in catlist|sort %}
                        {# Check to see if a dedicated category page exists #}
                        {% set slug = cat|hyphenize|url_encode %}
                        {% set p = page.find('/categories/'~slug) %}
                        {% if p == null %}
                                - {{ cat }}{% else %}
- {{ cat }}{% endif %}
                    {% endfor %}
{% endif %}
        {% elseif taxname == 'tag' %}
            {% if taxval %}Tag: {{ taxval }}
                    {% include 'partials/topiclist.html.twig' with {'articles': taxonomy.findTaxonomy({(taxname): taxval})} %}
                
            {% else %}
                
                    Tags
                    
                    {% for tag in taxonomy.taxonomy["tag"]|keys|sort %}
                        - {{ tag }}{% endfor %}
{% endif %}
        {% elseif taxname == 'author' %}
            {% if taxval %}Author: {{ taxval }}
                    {% include 'partials/topiclist.html.twig' with {'articles': taxonomy.findTaxonomy({(taxname): taxval})} %}
                
            {% else %}
                
                    Authors
                    
                    {% for author in taxonomy.taxonomy["author"]|keys|sort %}
                        {# Check to see if a dedicated author page exists #}
                        {% set slug = author|hyphenize|url_encode %}
                        {% set p = page.find('/authors/'~slug) %}
                        {% if p == null %}
                            - {{ author }}{% else %}
- {{ author }}{% endif %}
                    {% endfor %}
{% endif %}
        {% endif %}
    {% else %}
        
    {% endif %}
{% endblock %}