{% extends "vellum/base_vellum.html" %}
{% load i18n %}

{% block body_class %}{{ block.super }} archive{% endblock %}

{% block content %}
    <h1 class="page-title">{% block page_title %}{% trans "Post archive" %}{% endblock %}</h1>

    {% for post in object_list %}
        <article class="entry">
            <header>
                <h1 class="entry-title"><a href="{{ post.get_absolute_url }}" title="{% trans "Permalink to" %} {{ post.title }}">{{ post.title }}</a></h1>
                <time pubdate datetime="{{ post.publish|date:"c" }}">{{ post.publish|date }}</time>
                {% if perms.vellum.change_post %}
                <a title="{% trans "Edit" %} {{ post.title }}" class="edit" href="{% url admin:vellum_post_change post.id %}">Edit</a>
                {% endif %}
            </header>
            <div class="entry-content">
            {% if BLOG_EXCERPTS and post.excerpt %}
                {{ post.excerpt|safe }}
            {% else %}
                {{ post.body_rendered|safe }}
            {% endif %}
            </div>
            <footer>
                <p class="meta">This was posted{% if post.author %} by {{ post.author }}{%endif %} on <time pubdate datetime="{{ post.publish|date:"c" }}">{{ post.publish|date }}</time>{% if post.categories.all %} in {% for category in post.categories.all%}<a href="{% url vellum_category_detail slug=category.slug %}">{{ category }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}{% endif %}. {% if post.tags.all %}It was tagged with {% for tag in post.tags.all %}<a href="{% url vellum_tag_detail slug=tag.slug %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}.{% endif %}</p>
            </footer>
        </article>
    {% endfor %}

    {% if is_paginated %}
    <div class="pagination">
        {% if page_obj.has_next %}
        <a class="older" href="?page={{ page_obj.next_page_number }}" title="{% trans "View older posts" %}">&laquo; {% trans "Older" %}</a>
        {% endif %}
        {% if page_obj.has_previous %}<span class="separator">|</span>{% endif %}
        {% if page_obj.has_previous %}
        <a class="newer" href="?page={{ page_obj.previous_page_number }}" title="{% trans "View newer posts" %}">{% trans "Newer" %} &raquo;</a>
        {% endif %}
    </div>
    {% endif %}

{% endblock %}
