{% extends 'base.html' %} {% block content %}
<div class="row">
    {% if tag %} <div class="mx-auto">
        <h2> Artikel mit dem Tag "{{ tag.name }}" </h2>
    </div>{% endif %}
</div>
<div class="row">
    <div class="mx-auto">
        <h1> Artikleübersicht </h1>
    </div>
</div>
</div>
<div class="row">
    <div class="col-md-8">

        {% if messages %} 
        <div class="messages">
            {% for message in messages %}
            <p {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}</p>
            {% endfor %}
        </div>
        {% endif %}
        {% for post in posts %}
        <div class="mt-5 post">
            <div class="date">
                {{ post.published_date }}
            </div>
            <h2>
                <a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a>
            </h2>
            <p>{{ post.text|linebreaks }}</p>
            Tags: {% for tag in post.tags.all %}
            <a href="{% url 'post_list_by_tag' tag.slug %}">{{ tag.name }}</a>
            {% if not forloop.last %}, {% endif %} {% endfor %} <p>
                {{ post.author }}
            </p>
        </div>
        {% endfor %}
    </div>
</div>
{% endblock %}