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

{% block title %}
{% if category != None %}
分类页：{{ category.name }}
{% elif tag %}
标签页：{{ tag.name }}</h3>
{% else %}
首页
{% endif %}
{% endblock %}
{% load static %}
  <link rel="stylesheet" href="{% static 'css/bootstrap.css' %}">


{% block main %}
{% for post in post_list %}
<div class="card post">
    <div class="card-body">
        <h5 class="card-title"><a href="{% url 'post-detail' post.id %}">{{post.title}}</a></h5>
        <span class="card-link">作者：<a href="{% url 'author' post.owner.id %}">{{ post.owner.username }}</a> </span>
        <span class="card-link">分类：<a href="{% url 'category-list' post.category.id %}">{{ post.category.name }}</a> </span>
         <span class="card-link">标签：
             {% for tag in post.tags.all %}
             <a href="{% url 'tag-list' tag.id %}">{{ tag.name }}</a>
             {% endfor %}
         </span>
        <P class="card-text"><a href="{% url 'post-detail' post.id %}">完整内容</a></P>
    </div>
</div>
{% endfor %}

<br>
    {% 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 %}
</body>
</html>
