diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 4dcbd00cd30..7b0e16c28a0 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -87,10 +87,13 @@ const mapImgUrl = (img, block, type = 'block', from) => { ret = BLOG.RANDOM_IMAGE_URL } } - // 随机图片接口优化 防止因url一致而随机结果相同 - const separator = ret.includes('?') ? '&' : '?' - // 拼接唯一识别参数,防止请求的图片被缓存 - ret = `${ret.trim()}${separator}t=${block.id}` + + // 图片url优化,确保每一篇文章的图片url唯一 + if (ret && ret.length > 4) { + // 图片接口拼接唯一识别参数,防止请求的图片被缓,而导致随机结果相同 + const separator = ret.includes('?') ? '&' : '?' + ret = `${ret.trim()}${separator}t=${block.id}` + } } // 文章封面 @@ -101,8 +104,13 @@ const mapImgUrl = (img, block, type = 'block', from) => { return ret } +/** + * 是否是emoji图标 + * @param {*} str + * @returns + */ function isEmoji(str) { - const emojiRegex = /[\u{1F300}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F018}-\u{1F270}]/u; + const emojiRegex = /[\u{1F300}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F018}-\u{1F270}\u{238C}\u{2B06}\u{2B07}\u{2B05}\u{27A1}\u{2194}-\u{2199}\u{2194}\u{21A9}\u{21AA}\u{2934}\u{2935}\u{25AA}\u{25AB}\u{25FE}\u{25FD}\u{25FB}\u{25FC}\u{25B6}\u{25C0}\u{1F200}-\u{1F251}]/u; return emojiRegex.test(str); } diff --git a/themes/fukasawa/components/BlogCard.js b/themes/fukasawa/components/BlogCard.js index ba73eaedbe7..8b68a26a53b 100644 --- a/themes/fukasawa/components/BlogCard.js +++ b/themes/fukasawa/components/BlogCard.js @@ -61,8 +61,7 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => { }
- - {post.tagItems.map((tag) => ( + {post.tagItems?.map((tag) => ( ))}
diff --git a/themes/fukasawa/index.js b/themes/fukasawa/index.js index 7ab72892198..3786c20d4b7 100644 --- a/themes/fukasawa/index.js +++ b/themes/fukasawa/index.js @@ -48,12 +48,14 @@ const LayoutBase = (props) => { const leftAreaSlot = const { onLoading } = useGlobal() + const FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT = siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT', null, CONFIG) + // 侧边栏折叠从 本地存储中获取 open 状态的初始值 const [isCollapsed, setIsCollapse] = useState(() => { if (typeof window !== 'undefined') { - return localStorage.getItem('fukasawa-sidebar-collapse') === 'true' || siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT', null, CONFIG) + return localStorage.getItem('fukasawa-sidebar-collapse') === 'true' || FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT } - return siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT', null, CONFIG) + return FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT }) // 在组件卸载时保存 open 状态到本地存储中