</div>

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

<!-- 侧边栏 -->
<aside class="sidebar">
<!-- 网站公告 -->
{if $announcements}
<div class="sidebar-widget">
<div class="widget-title">
<span>📢</span>网站公告
</div>
<div class="list-group">
{foreach $announcements as $announcement}
<div class="list-group-item" style="flex-direction: column; align-items: flex-start;">
<h6>{$announcement.title}</h6>
<small class="text-muted">{$announcement.content}</small>
<small class="text-muted" style="margin-top: 5px;">📅 {$announcement.time}</small>
</div>
{/foreach}
</div>
</div>
{/if}

{* 侧边栏顶部广告 *}
{if $config.ads.sidebar_top.enabled}
<div class="sidebar-ad top-ad">
{$config.ads.sidebar_top.content}
</div>
{/if}

<!-- 侧边栏自定义数据钩子 -->
{display_custom_data position='sidebar' page_type=$mod}

<!-- 分类列表 -->
<div class="sidebar-widget">
<div class="widget-title">
<span>📁</span>文章分类
</div>
<ul class="category-list">
<li class="category-item">
<a href="{build_url mod='index'}">
全部文章
<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}">
{$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">
<span>🔥</span>热门文章
</div>
<div class="list-group">
{foreach $hot_posts as $post}
<a href="{build_url mod='post' id=$post.id}" class="list-group-item">
<h6>{$post.title|truncate:25}</h6>
<small class="text-muted">
<span>👁️</span>{$post.views} 阅读
</small>
</a>
{/foreach}
</div>
</div>
{/if}

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

{* 侧边栏底部广告 *}
{if $config.ads.sidebar_bottom.enabled}
<div class="sidebar-ad top-ad">
{$config.ads.sidebar_bottom.content}
</div>
{/if}

<!-- 友情链接 -->
{if $friend_links}
<div class="sidebar-widget">
<div class="widget-title">
<span>🔗</span>友情链接
</div>
<div class="friend-links">
{foreach $friend_links as $link}
<a href="{$link.url}" target="_blank" class="friend-link" title="{$link.description}">
{$link.name}
</a>
{/foreach}
</div>
</div>
{/if}
</aside>
</div>
</main>

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

<!-- 页脚 -->
<footer class="footer">
<div class="container">
<div class="footer-content">
<div>
<h5>
<span>📝</span>{$config.site.name}
</h5>
<p class="mb-2">{$config.site.description}</p>
<p class="text-muted">
<span>©</span>2025 {$config.site.name}. 版权所有  Powered By <a href="https://www.wszzw.cn/" target="_blank">文煞CMS</a>
</p>
</div>
<ul class="footer-links">
<li><a href="{resource_url}">首页</a></li>
<li><a href="#">关于我们</a></li>
<li><a href="#">联系方式</a></li>
</ul>
</div>
{if $config.site.statistics}
<div class="text-center mt-3">
{$config.site.statistics}
</div>
{/if}
</div>
</footer>

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

<!-- 缓存更新脚本 -->
<script>
function updateCache() {
fetch('{build_url mod="update_cache"}')
.then(response => response.json())
.then(data => {
if (data.code === 200) {
alert('缓存更新成功');
} else {
alert('缓存更新失败: ' + data.message);
}
})
.catch(error => {
console.error('Error:', error);
alert('缓存更新请求失败');
});
}

// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
// 可以在这里添加自动缓存更新的逻辑
// 例如：每10分钟检查一次是否需要更新缓存
});
</script>
</body>
</html>