diff --git a/components/TagItem.js b/components/TagItem.js
index efd322fd..c9d6a4a7 100644
--- a/components/TagItem.js
+++ b/components/TagItem.js
@@ -2,8 +2,13 @@ import { faTag } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Link from 'next/link'
import React from 'react'
+import { useGlobal } from '@/lib/global'
const TagItem = ({ tag, selected }) => {
+ const { locale } = useGlobal()
+ if (!tag) {
+ <>{locale.COMMON.NOTAG}>
+ }
return (
{ return { name: tag, color: tagOptions.find(t => t.value === tag).color } }) || ['默认']
properties.createdTime = new Date(pageBlock[id].value?.created_time).toString()
properties.lastEditedTime = new Date(pageBlock[id].value?.last_edited_time).toString()
properties.fullWidth = pageBlock[id].value?.format?.page_full_width ?? false
properties.page_cover = getPostCover(id, pageBlock) ?? BLOG.defaultImgCover
properties.content = pageBlock[id].value?.content ?? []
- properties.tagItems = tagItems
+ properties.tagItems = properties?.tags?.map(tag => {
+ return { name: tag, color: tagOptions.find(t => t.value === tag)?.color || 'gray' }
+ }) || []
data.push(properties)
}
diff --git a/lib/notion/getAllTags.js b/lib/notion/getAllTags.js
index 96af611c..1fe5523f 100644
--- a/lib/notion/getAllTags.js
+++ b/lib/notion/getAllTags.js
@@ -26,7 +26,7 @@ export async function getAllTags ({ allPosts, sliceCount = 12, tagOptions }) {
// 按照标签数量排序
const list = Object.keys(tagObj).map((tag) => {
- const color = tagOptions.find(option => option.value === tag).color
+ const color = tagOptions.find(option => option.value === tag)?.color || 'gray'
return { name: tag, count: tagObj[tag], color }
})
list.sort((a, b) => b.count - a.count)