{% extends 'base.html' %}

{% block title %}{{ category.category_name }} Category{% endblock %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <h1>{{ category.category_name }}</h1>
            <a href="{{ url_for('create_post', category_id=category.id) }}" class="btn btn-primary mb-3">Create Post</a>
            <div class="card mt-4">
                <div class="card-body">
                    <div class="list-group">
                        {% for post in posts %}
                        <a href="{{ url_for('view_post', post_id=post.id) }}" class="list-group-item list-group-item-action">
                            <h5 class="mb-1">{{ post.post_name }}</h5>
                            <p class="mb-1">{{ post.text }}</p>
                            <small>Created by {{ post.created_by }} - {{ post.creation_date }}</small>
                        </a>
                        {% endfor %}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}