Files
blogsite/blog/templates/category_detail.html
T

87 lines
4.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "base.html" %}
{% block title %}{{ category.name }} - 郭安的小站{% endblock %}
{% block content %}
<div style="margin-bottom: 2rem;">
<h2 style="
font-size: 1.1rem;
font-weight: 600;
color: var(--text);
margin-bottom: 0.3rem;
">{{ category.name }}</h2>
{% if category.description %}
<p style="font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.5rem;">{{ category.description }}</p>
{% endif %}
{% for post in posts %}
<div class="post-item">
<h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
<div class="post-date">{{ post.published_at|date:"Y年m月d日" }}</div>
{% if post.excerpt %}
<div class="post-summary">{{ post.excerpt }}</div>
{% endif %}
</div>
{% empty %}
<div class="post-item" style="text-align: center; padding: 4rem 0; color: var(--text-muted);">
<p>这个分类下还没有文章</p>
</div>
{% endfor %}
<!-- 分页 -->
{% if posts.paginator.num_pages > 1 %}
<nav style="
margin-top: 3rem;
text-align: center;
font-family: -apple-system, 'Noto Sans SC', sans-serif;
font-size: 0.9rem;
">
{% if posts.has_previous %}
<a href="?page=1" style="margin-right: 0.6rem; color: var(--text-light); text-decoration: none;">« 首页</a>
<a href="?page={{ posts.previous_page_number }}" style="margin-right: 1rem; color: var(--text-light); text-decoration: none;">‹ 上一页</a>
{% else %}
<span style="margin-right: 0.6rem; color: var(--text-muted);">« 首页</span>
<span style="margin-right: 1rem; color: var(--text-muted);">‹ 上一页</span>
{% endif %}
{% for num in posts.paginator.page_range %}
{% if posts.paginator.num_pages <= 9 %}
{% if num == posts.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% else %}
{% if num == 1 or num == posts.paginator.num_pages %}
{% if num == posts.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% elif num >= posts.number|add:'-2' and num <= posts.number|add:'2' %}
{% if num == posts.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% elif num == posts.number|add:'-3' or num == posts.number|add:'3' %}
<span style="margin: 0 0.2rem; color: var(--text-muted);">…</span>
{% endif %}
{% endif %}
{% endfor %}
{% if posts.has_next %}
<a href="?page={{ posts.next_page_number }}" style="margin-left: 1rem; color: var(--text-light); text-decoration: none;">下一页 ›</a>
<a href="?page={{ posts.paginator.num_pages }}" style="margin-left: 0.6rem; color: var(--text-light); text-decoration: none;">末页 »</a>
{% else %}
<span style="margin-left: 1rem; color: var(--text-muted);">下一页 ›</span>
<span style="margin-left: 0.6rem; color: var(--text-muted);">末页 »</span>
{% endif %}
</nav>
{% endif %}
<div style="margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted); font-family: -apple-system, 'Noto Sans SC', sans-serif;">
<a href="/" style="color: var(--text-light); text-decoration: none;">← 返回分类列表</a>
</div>
</div>
{% endblock %}