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

<!-- 文章前自定义数据钩子 -->
{display_custom_data position='before_post' page_type=$mod}

<article class="article-card">
    <header class="article-header">
        <h1 class="article-title">{$post.title nofilter}</h1>

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

    <div class="article-content">
        {* 文章顶部广告 *}
        {if $config.ads.post_top.enabled}
        <div class="post-ad top-ad" style="margin-bottom: 2rem; text-align: center; padding: 20px; background: var(--light-color); border-radius: var(--border-radius);">
            {$config.ads.post_top.content}
        </div>
        {/if}

        {$post.content nofilter}

        {* 文章底部广告 *}
        {if $config.ads.post_bottom.enabled}
        <div class="post-ad bottom-ad" style="margin-top: 2rem; text-align: center; padding: 20px; background: var(--light-color); border-radius: var(--border-radius);">
            {$config.ads.post_bottom.content}
        </div>
        {/if}
    </div>

    <footer class="article-footer">
        {if $post.tags_array}
        <div class="article-tags">
            {foreach $post.tags_array as $tag}
            {if $tag}
            <a href="{build_url mod='search' keyword=$tag}" class="tag">#{$tag}</a>
            {/if}
            {/foreach}
        </div>
        {/if}

        <div style="display: flex; gap: 15px; flex-wrap: wrap;">
            <a href="{build_url mod='index'}" class="read-more">← 返回文章列表</a>
                ↑ 回到顶部
            </button>
        </div>
    </footer>
</article>

<!-- 文章后自定义数据钩子 -->
{display_custom_data position='after_post' page_type=$mod}

{include file="footer.tpl"}