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

{% block title %}
        {% if tag %}
        标签页：{{ tag.name }}
        {% elif category %}
        分类页：{{ category.name }}
        {% else %}
        首页
        {% endif %}
{% endblock %}

{% block main %}
    <ul>
        {% for post in post_list %}
            <li>
{#                <a href="/post/{{ post.id }}.html">{{ post.title }}</a>#}
                <a href="{% url 'post-detail' post.id %} ">{{ post.title }}</a>
                <div>
                    <span>作者：{{ post.owner.username }}</span>
                    <span>分类：{{ post.category.name }}</span>
                    <span>标签:
                        {% for tag in post.tag.all %}
                        <a href="{% url 'tag-list' tag.id %}">{{ tag.name }}</a>
                        {% endfor %}
                    </span>
                    <hr/>

                </div>
                <p>{{ post.desc }}</p>
            </li>
        {% endfor %}
    </ul>

    {% if page_obj %}
        {% if page_obj.has_previous %}
            <a href="?page={{ page_obj.previous_page_number }}">上一页</a>
            {% endif %}
        page{{ page_obj.number }}of{{ paginator.num_pages }}.
        {% if page_obj.has_next %}
            <a href="?page={{ page_obj.next_page_number }}">下一页</a>
            {% endif %}

    {% endif %}

{% endblock %}




