</div>

<!-- 内容后自定义数据钩子 -->
{display_custom_data position='after_content' page_type=$mod}

<!-- 侧边栏 -->
<aside class="sidebar">
    <!-- 搜索框 -->
    <div class="sidebar-widget">
        <div class="widget-title">🔍 搜索文章</div>
        <form class="search-form" action="{build_url mod='search'}" method="get">
            <input type="hidden" name="mod" value="search">
            <input type="text" name="keyword" class="search-input" placeholder="输入关键词..." value="{$keyword|default:''}">
            <button type="submit" class="search-button">搜索</button>
        </form>
    </div>
    <div class="sidebar-widget">
    <!-- 侧边栏自定义数据钩子 -->
    {display_custom_data position='sidebar' page_type=$mod}
    </div>

    <!-- 分类列表 -->
    <div class="sidebar-widget">
        <div class="widget-title">📁 文章分类</div>
        <ul class="category-list">
            <li class="category-item">
                <a href="{build_url mod='index'}" class="category-link">
                    全部文章
                    <span class="category-count">{$total_posts|default:0}</span>
                </a>
            </li>
            {foreach $all_categories as $category}
            <li class="category-item">
                <a href="{build_url mod='category' cate=$category.id}" class="category-link">
                    {$category.name}
                    <span class="category-count">{$category.count|default:0}</span>
                </a>
            </li>
            {/foreach}
        </ul>
    </div>

    <!-- 热门文章 -->
    {if $hot_posts}
    <div class="sidebar-widget">
        <div class="widget-title">🔥 热门文章</div>
        <ul class="post-list-widget">
            {foreach $hot_posts as $post}
            <li class="post-list-item">
                <a href="{build_url mod='post' id=$post.id}" class="post-list-link">
                    <div class="post-list-title">{$post.title|truncate:25}</div>
                    <div class="post-list-meta">👁️ {$post.views} 阅读</div>
                </a>
            </li>
            {/foreach}
        </ul>
    </div>
    {/if}

    <!-- 随机文章 -->
    {if $random_posts}
    <div class="sidebar-widget">
        <div class="widget-title">🎲 随机推荐</div>
        <ul class="post-list-widget">
            {foreach $random_posts as $post}
            <li class="post-list-item">
                <a href="{build_url mod='post' id=$post.id}" class="post-list-link">
                    <div class="post-list-title">{$post.title|truncate:25}</div>
                    <div class="post-list-meta">📅 {$post.create_time|date_format:'Y-m-d'}</div>
                </a>
            </li>
            {/foreach}
        </ul>
    </div>
    {/if}

    <!-- 投稿组件 -->
    <div class="sidebar-widget contribution-widget">
        <div class="contribution-icon">📝</div>
        <div class="contribution-title">欢迎投稿</div>
        <div class="contribution-desc">分享您的文学创作，让更多人看到您的作品</div>
        <a href="mailto:{$config.site.email|default:'contribute@yourdomain.com'}" class="contribution-email">立即投稿</a>
    </div>

    {* 侧边栏广告 *}
    {if $config.ads.sidebar.enabled}
    <div class="sidebar-widget">
        <div class="widget-title">📢 推荐</div>
        <div style="text-align: center; padding: 15px;">
            {$config.ads.sidebar.content}
        </div>
    </div>
    {/if}
</aside>
</div>
</main>

<!-- 页脚自定义数据钩子 -->
{display_custom_data position='footer' page_type=$mod}

<!-- 网站页脚 -->
<footer class="site-footer">
    <div class="container">
        <div class="footer-content">
            <div class="footer-widget">
                <div class="footer-widget-title">关于 {$config.site.name}</div>
                <p>{$config.site.description}</p>
                <div style="margin-top: 15px;">
                    <div class="meta-item" style="display: inline-flex; background: rgba(255,255,255,0.1); color: white;">
                        <span>📧</span> {$config.site.email|default:'contact@yourdomain.com'}
                    </div>
                </div>
            </div>

            <div class="footer-widget">
                <div class="footer-widget-title">快速导航</div>
                <ul class="footer-links">
                    <li><a href="{resource_url}">网站首页</a></li>
                    <li><a href="#">关于我们</a></li>
                </ul>
            </div>

            <div class="footer-widget">
                <div class="footer-widget-title">友情链接</div>
                <div class="friend-links">
                    {if $friend_links}
                    {foreach $friend_links as $link}
                    <a href="{$link.url}" target="_blank" class="friend-link" title="{$link.description}">
                        {$link.name}
                    </a>
                    {/foreach}
                    {else}
                    <span style="color: rgba(255,255,255,0.6);">暂无友链</span>
                    {/if}
                </div>
            </div>
        </div>

        <div class="footer-bottom">
            <p>&copy; 2025 {$config.site.name}. 保留所有权利. Powered By <a href="https://www.wszzw.cn/" target="_blank" style="color: var(--secondary-color);">文煞CMS</a></p>
            {if $config.site.statistics}
            <div style="margin-top: 10px;">
                {$config.site.statistics}
            </div>
            {/if}
        </div>
    </div>
</footer>

<!-- JavaScript -->
<script src="{resource_url path='templates/literary/js/script.js'}"></script>
</body>
</html>