优化 tags 不存在问题

This commit is contained in:
Han
2025-04-07 13:47:47 +08:00
parent ffebcb1099
commit a2d19f5045
5 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -56,9 +56,9 @@ import "@/styles/ArticleBase.less";
</header>
<main>
<Content />
<nav class="tag-list">
<section class="tag-list">
{
post.data.tags.map((i: any) => (
(post.data.tags || []).map((i: any) => (
<a href={`/tag/${i}`}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
@@ -69,7 +69,7 @@ import "@/styles/ArticleBase.less";
</a>
))
}
</nav>
</section>
</main>
<footer>
<!-- 打赏组件 -->
+1 -1
View File
@@ -4,7 +4,7 @@ import { getCollection } from "astro:content";
export async function getStaticPaths(): Promise<any> {
const posts = await getCollection("blog");
let tagList: any = [];
posts.forEach(post => (tagList = [...tagList, ...post.data.tags]));
posts.forEach(post => (tagList = [...tagList, ...(post.data.tags || [])]));
return [...new Set(tagList)].map(tags => ({ params: { tags } }));
}
// 获取分类列表