{% extends 'base.html' %}

{% block content %}
    <div class="container">
        <form class="d-flex" method="GET">
            <input name="search" class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
            <button class="btn btn-outline-success" type="submit">Search</button>
        </form>
        <table class="table">
          <thead>
            <tr>
              <th scope="col">#</th>
              <th scope="col">Title</th>
              <th scope="col">Author</th>
              <th scope="col">Date</th>
              <th scope="col">Action</th>
            </tr>
          </thead>
          <tbody>
            {% for article in articles %}
                <tr>
                  <th scope="row">{{ forloop.counter }}</th>
                  <td><a href="{% url 'article_detail' article.pk %}">{{ article.title }}</a></td>
                  <td>{{ article.author }}</td>
                  <td>{{ article.created_at|date:"d M Y" }}</td>
                  <td><a class="btn btn-danger btn-sm" href="{% url "article_delete" article.pk %}">Удалить</a></td>
                </tr>
            {% endfor %}
          </tbody>
        </table>
        <a href="{% url 'article_create' %}">Создать статью</a>
        <a href="{% url 'author_create' %}">Создать автора</a>
        {% include 'partial/pagination.html' %}
    </div>
{% endblock %}