{% extends "layouts/default.twig" %}

{% block content %}
{% if archives %} {# List? (For all/yearly archives) #}
                    {% if GET.year != null %}
                    <h1>${ "Archive of %s" | translate | format((archives | first).year) }</h1>
                    {% else %}
                    <h1>${ "Archives" | translate }</h1>
                    {% endif %}
                    {% for archive in archives %}
                    {% if GET.year != null %}
                    <h2><a href="$archive.url">${ archive.timestamp | strftime("%B" | translate) }</a></h2>
                    {% else %}
                    <h2><a href="$archive.url">${ archive.timestamp | strftime("%B %Y" | translate) }</a></h2>
                    {% endif %}
                    <ul>
                        {% for post in archive.posts %}
                        <li>${ post.created_at | strftime("%d" | translate) }: <a href="$post.url">${ post.title | normalize | truncate(70) }</a></li>
                        {% endfor %}
                    </ul>
                    <br />
                    {% endfor %}
{% endif %}

{% if posts.paginated %} {# Posts? (For daily/monthly archives) #}
                    {% if archive.depth == "day" %}
                    <h1>${ "Archive of %s" | translate | format(archive.timestamp | strftime("%B %d, %Y" | translate)) }</h1>
                    {% endif %}
                    {% if archive.depth == "month" %}
                    <h1>${ "Archive of %s" | translate | format(archive.timestamp | strftime("%B %Y" | translate)) }</h1>
                    {% endif %}
                    {% for post in posts.paginated %}
                    {% include "feathers/" ~ post.feather ~ ".twig" %}
                    {% endfor %}
{% endif %}

{% if not archives and not posts.paginated %} {# No results #}
                    <h2>${ "No Posts" | translate }</h2>
                    <p>${ "There aren't any posts in the timeframe you specified." | translate }</p>
{% endif %}
{% endblock %}
