{% extends 'base.html' %}

{% block content %}
<div class="post-preview">
{% if data|length > 0 %}
{% for d in data %}
<!-- Post preview-->
<div class="post-preview">
    <div class="d-flex justify-content-between">
        <div class="p-2">
            <a href="{% url 'reader' d.url.id %}">
                <h2 class="post-title">{% if d.title %}{{ d.title }}{% else %}Без заголовка{% endif %}</h2>
            </a>
        </div>
        <div class="p-2">
            <a href="/delete/{{ d.url.id }}"><span class="fa-regular fa-trash-can"></span></a>
        </div>
    </div>
    {% if d.short %}
    <p class="post-meta">
        {{ d.short }}
    </p>
    {% endif %}
    <p class="post-meta">
        <a href="{{ d.url.url }}">
            {{ d.url.url }}
        </a>
    </p>
</div>
<!-- Divider-->
<hr class="my-4" />
{% endfor %}

{% if data.number %}
<div class="pagination container row justify-content-end">
    <div></div>
    <div class="step-links col-auto">
        {% if data.has_previous %}
        <a href="?page=1">&laquo;</a>
        <a href="?page={{ data.previous_page_number }}">&lsaquo;</a>
        {% endif %}

        <span class="current">
            страница {{ data.number }} из {{ data.paginator.num_pages }}
        </span>

        {% if data.has_next %}
        <a href="?page={{ data.next_page_number }}">&rsaquo;</a>
        <a href="?page={{ data.paginator.num_pages }}">&raquo;</a>
        {% endif %}
    </div>
</div>
{% endif %}
{% else %}
    <h2 class="post-title">У вас нет ссылок в архиве</h2>
{% endif %}
</div>
{% endblock %}
