{% extends "base.html" %}

{% block content %}
<div class="container mt-5">
    <h1 class="text-center mb-4">Blog</h1>
    <div class="row">
        {% for post in posts %}
        <div class="col-md-8 offset-md-2">
            <div class="card mb-4">
                <div class="card-body">
                    <h2 class="card-title"><a href="{% url 'post_detail' post.slug %}">{{ post.title }}</a></h2>
                    <p class="card-text">{{ post.content|truncatewords:50 }}</p>
                    <a href="{% url 'post_detail' post.slug %}" class="btn btn-primary">Read More &rarr;</a>
                </div>
                <div class="card-footer text-muted">
                    Posted on {{ post.created_at|date:"F d, Y" }} by
                    <a href="#">{{ post.author }}</a>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
</div>
{% endblock %}
