{include file="header.tpl"}

<h1 class="mb-4">{$current_category.name}</h1>
{if $current_category.description}
<p class="lead text-muted mb-4">{$current_category.description}</p>
{/if}

<!-- 分类列表前自定义数据钩子 -->
{display_custom_data position='before_category' page_type=$mod}

{if $posts}
{assign var="name" value="value"}

<div class="post-list">
{foreach $posts as $post}
<article class="post-card">
<h2 class="post-title">
<a href="{build_url mod='post' id=$post.id}">{$post.title nofilter}</a>
</h2>
<div class="post-meta">
<span><i class="fas fa-user me-1"></i>{$post.author}</span>
<span><i class="fas fa-calendar me-1"></i>{$post.create_time|date_format:'Y-m-d H:i'}</span>
<span><i class="fas fa-eye me-1"></i>{$post.views} 阅读</span>
</div>
<div class="post-content">
{$post.content|truncate:200}
</div>
</article>
{/foreach}
</div>

<!-- 分类列表后自定义数据钩子 -->
{display_custom_data position='after_category' page_type=$mod}

{if $pagination.total_pages > 1}
<nav class="pagination">
{if $pagination.has_prev}
<a href="{build_url mod='category' cate=$current_category.id page=$pagination.page_prev}" class="page-link">上一页</a>
{/if}

{foreach $pagination.display_pages as $p}
{if $p == $pagination.page}
<span class="page-link page-current">{$p}</span>
{else}
<a href="{build_url mod='category' cate=$current_category.id page=$p}" class="page-link">{$p}</a>
{/if}
{/foreach}

{if $pagination.has_next}
<a href="{build_url mod='category' cate=$current_category.id page=$pagination.page_next}" class="page-link">下一页</a>
{/if}
</nav>
{/if}
{else}
<div class="text-center py-5">
<i class="fas fa-inbox fa-3x text-muted mb-3"></i>
<p class="text-muted">该分类下暂无文章</p>
</div>
{/if}

{include file="footer.tpl"}