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

{% block content %}
{% if archives %} {# List? (For all/yearly archives) #}
                    {% if GET.year != null %}
                    {% for archive in archives %}
                    <h1>${ "Archive of %s" | translate | format(archive.year) }</h1>
                    {% endfor %}
                    {% 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 %e, %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 %}
