{% extends 'base.html' %}

{% block title %}Поиск{% endblock %}


{%  block content %}
<form action="{% url 'search' %}" method="post">
    {% csrf_token %}
    <input type="text" name="search" placeholder="Что ищем?">
    <input type="submit" value="Искать" />
</form>
<br />
        {% 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">{{ d.title }}</h2>
                        </a>
                    </div>
                    <div class="p-2">
                        <a href="{% url 'archive_url' d.url.id %}"><span class="fa-regular fa-square-check"></span></a>
                    </div>
                </div>
                {% if d.short %}
                <p class="post-meta">
                    {{ d.short }}
                </p>
                {% endif %}
                <p class="post-meta">
                    {{ d.url.url|urlizetrunc:70 }}
                </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 %}
{% endblock %}
