{include file="header.tpl"}

<h1 class="mb-4">{$author_name}的文章</h1>

{if $posts}
<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-folder me-1"></i>{$post.category}</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>
<span><i class="fas fa-comment me-1"></i>{$post.comments} 评论</span>
</div>
<div class="post-content">
{$post.content|truncate:200}
</div>
</article>
{/foreach}
</div>

{if $pagination.total_pages > 1}
<nav class="pagination">
{if $pagination.has_prev}
<a href="{build_url mod='author' author=$author_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='author' author=$author_id page=$p}" class="page-link">{$p}</a>
{/if}
{/foreach}

{if $pagination.has_next}
<a href="{build_url mod='author' author=$author_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"}