{% extends "base.html" %}
{% load static %}

{% block content %}
  <h1 class="display-3">{{ blog.title }}</h1>
  <p class="lead">
    {{ blog.description }}
  </p>
  <a href="{% url "cast:post_feed" slug=blog.slug %}"><img src='/static/images/Feed-icon.svg'></img></a>
  {% if user.is_authenticated %}
      <a class="btn btn-primary btn-lg" role="button" href="{% url "cast:post_create" slug=blog.slug %}">Create Arcticle</a>
  {% endif %}
  <hr class="my-4">

{% for post in posts %}
  <article>
    <header>
      <h1>{{ post.title }}</h1>
      <a href="{% url "cast:post_detail" blog_slug=blog.slug slug=post.slug %}">
        <time date-time="{{ post.visible_date|date:"c" }}">{{ post.visible_date|date}}</time>
        - {{ post.author.username | title}}
      </a>
    </header>
    <section>
      {{ post.description|safe }}
    </section>
  </article>
  <hr class="my-4">
{% endfor %}

<nav aria-label="pagination">
  <ul class="pagination">
    {% if page_obj.has_previous %}
      <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">future</a><li>
    {% endif %}
    {% if page_obj.has_next %}
      <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">past</a></li>
    {% endif %}
  </ul>
</nav>
{% endblock content %}

{% block template_script %}
<script src="{% static 'js/cast/gallery.js' %}"></script>
{% endblock template_script %}
