Skip to content

Commit

Permalink
Merge pull request tangly1024#1649 from tangly1024/fix/img-optimization
Browse files Browse the repository at this point in the history
some small fix about img font
  • Loading branch information
tangly1024 authored Nov 21, 2023
2 parents 8d7b1e2 + 67d3e16 commit 2debdf1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
18 changes: 13 additions & 5 deletions lib/notion/mapImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
}

// 文章封面
Expand All @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions themes/fukasawa/components/BlogCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => {
</Link>}
<div className="md:flex-nowrap flex-wrap md:justify-start inline-block">
<div>

{post.tagItems.map((tag) => (
{post.tagItems?.map((tag) => (
<TagItemMini key={tag.name} tag={tag} />
))}
</div>
Expand Down
6 changes: 4 additions & 2 deletions themes/fukasawa/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ const LayoutBase = (props) => {
const leftAreaSlot = <Live2D />
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 状态到本地存储中
Expand Down

1 comment on commit 2debdf1

@vercel
Copy link

@vercel vercel bot commented on 2debdf1 Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.