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

    {% block styles %}
        <link rel="stylesheet" type="text/css" href="{% static 'forum/style.css' %}">   
    {% endblock %}

{% block title %}Welcome to Widget's Forum{% endblock %}
{% block content %}
    <h1>Forum</h1>
        <div>
            <h2>Forum posts:</h2>
            <ul>
                {% if posts %}
                    {% for post in posts %}
                        <li><a href="{% url 'forum:details' post.id%}">{{post.post_title}}</a> by {{post.author.first_name}} {{post.author.last_name}} dated {{post.pub_date|date:"d/m/Y"}}</li>
                    {% endfor %}
                {% else %}
                    <p>There is no post.</p>
                {% endif %}
            <button onclick="window.location.href='/forum/add'"">Write a new forum post</button>
            </ul>
        </div>
{% endblock %}