Skip to content

Commit

Permalink
Notion新图床兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Feb 2, 2025
1 parent 1c2013d commit 280bb79
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/notion/mapImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ const mapImgUrl = (img, block, type = 'block', needCompress = true) => {
ret = img
}

// Notion 图床转换为永久地址
const hasConverted =
ret.indexOf('https://www.notion.so/image') === 0 ||
ret.includes('notion.site/images/page-cover/')
ret.indexOf('https://www.notion.so/image') === 0 ||
ret.includes('notion.site/images/page-cover/')

// 需要转化的URL ; 识别aws图床地址,或者bookmark类型的外链图片
// Notion新图床资源 格式为 attachment:${id}:${name}
const needConvert =
!hasConverted &&
(block.type === 'bookmark' ||
ret.includes('secure.notion-static.com') ||
ret.includes('prod-files-secure'))
ret.includes('prod-files-secure')) ||
ret.indexOf('attachment')===0


// 使用Notion图传
// Notion旧图床
if (needConvert) {
ret =
BLOG.NOTION_HOST +
Expand Down

0 comments on commit 280bb79

Please sign in to comment.