<!-- templates/literary/category.tpl -->
{include file="header.tpl"}

<!-- 分类横幅 -->
<div class="hero-banner mb-4" style="background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%); color: white; padding: 50px 40px; border-radius: var(--border-radius);">
    <h1 style="font-size: 2.2rem; margin-bottom: 15px;">{$current_category.name}</h1>
    {if $current_category.description}
    <p style="font-size: 1.1rem; opacity: 0.9;">{$current_category.description}</p>
    {/if}
    <div class="meta-item" style="background: rgba(255,255,255,0.2); color: white; margin-top: 15px; display: inline-block;">
        <span>📚</span> 共 {$pagination.total|default:0} 篇文章
    </div>
</div>

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

<!-- 分类文章列表 -->
{if $posts}
{foreach $posts as $post}
<article class="article-card">
    <h2 class="article-title">
        <a href="{build_url mod='post' id=$post.id}">{$post.title nofilter}</a>
    </h2>

    <div class="article-meta">
        <div class="meta-item">
            <span>👤</span> {$post.author}
        </div>
        <div class="meta-item">
            <span>📅</span> {$post.create_time|date_format:'Y-m-d H:i'}
        </div>
        <div class="meta-item">
            <span>👁️</span> {$post.views} 阅读
        </div>
        {if $post.comments}
        <div class="meta-item">
            <span>💬</span> {$post.comments} 评论
        </div>
        {/if}
    </div>

    <div class="article-excerpt">
        {$post.content|truncate:200}
    </div>

    <div class="article-footer">
        <a href="{build_url mod='post' id=$post.id}" class="read-more">阅读全文 →</a>
    </div>
</article>
{/foreach}

<!-- 分类列表后自定义数据钩子 -->
{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="article-card text-center">
    <div style="font-size: 3rem; margin-bottom: 20px; color: var(--text-light);">📂</div>
    <h2 style="color: var(--text-light);">该分类下暂无文章</h2>
    <p style="color: var(--text-light);">这个分类还没有发布任何文章。</p>
    <a href="{build_url mod='index'}" class="read-more">返回首页</a>
</div>
{/if}

{include file="footer.tpl"}