{% extends "components/base.html" %}

{% block title %}Post{% endblock %}

{% block main_area %}
  <h1 class="pt-3">Blog Posts</h1>
  {% if request.user.is_authenticated %}
    <a href="{% url 'blog:create_post' %}" class="btn btn-primary mb-3">Create New Post</a>
  {% endif %}
  <ul class="list-group">
    {% for post in posts %}
      <li class="list-group-item">
        <h5>{{ post.title }}</h5>
        <p>{{ post.summary }}</p>
        <a href="{% url 'blog:post_detail' post.pk %}" class="btn btn-secondary">Read More</a>
      </li>
    {% endfor %}
  </ul>
{% endblock %}