{% extends "base.html" %}
{% import "macros/taxonomy.html" as macros %}
{% import "macros/post.html" as posts %}
{% import "macros/feed.html" as feed_macros %}

{%- block title -%}
{{ term.name | title }} | {{ config.title }}
{%- endblock -%}

{%- block feeds -%}
    {%- if taxonomy.feed -%}
        {%- for filename in config.feed_filenames -%}
        
            {%- if taxonomy.name is ending_with("ies") -%}
                {%- set singular_name = taxonomy.name | replace(from="ies", to="y") -%}
            {%- else -%}
                {%- set singular_name = taxonomy.name | trim_end_matches(pat="s") -%}
            {%- endif -%}
            {%- set feed_title = config.title ~ " | Posts in the '" ~ term.name ~ "' " ~ singular_name -%}
            {%- set feed_filename = taxonomy.name ~ "/" ~ term.name ~ "/" ~ filename -%}
            {{ feed_macros::link_alternate(filename=feed_filename, title=feed_title) }}

        {% endfor -%}
    {%- endif -%}
{%- endblock -%}


{%- block main -%}

<h1>{{ macros::prettify(term=term.name) }}</h1>
<div>
{%- for page in paginator.pages | default(value=term.pages) %}
    {{ posts::excerpt(page=page) }}
{%- endfor %}
</div>

{%- endblock -%}