修复图片显示

This commit is contained in:
tangly1024
2023-06-18 10:31:02 +08:00
parent 20917b47a4
commit 2cd67c1d82
2 changed files with 20 additions and 12 deletions

View File

@@ -9,29 +9,37 @@ const compressImage = (image) => {
return image + '&width=200'
}
}
/**
* Notion图片映射处理有emoji的图标
* 图片映射
* 1. 如果是 /xx.xx 相对路径格式,则转化为 完整notion域名图片
* 2. 如果是 bookmark类型的block 图片封面无需处理
* @param {*} img
* @param {*} value
* @returns
*/
const mapImgUrl = (img, block, type = 'block') => {
let ret = null
if (!img) {
return ret
return null
}
let ret = null
// 相对目录则视为notion的自带图片
if (img.startsWith('/')) {
ret = BLOG.NOTION_HOST + img
}
// 书签的地址本身就是永久链接,无需处理
if (!ret && block?.type === 'bookmark') {
} else {
ret = img
}
// notion永久图床地址
if (!ret && ret !== null && ret.indexOf('secure.notion-static.com') > 0 && (BLOG.IMG_URL_TYPE === 'Notion' || type !== 'block')) {
// 书签的地址本身就是永久链接,无需处理
if (block?.type === 'bookmark') {
ret = img
}
// notion 图床转换为永久图床地址
if (ret.indexOf('secure.notion-static.com') > 0 && (BLOG.IMG_URL_TYPE === 'Notion' || type !== 'block')) {
ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + '?table=' + type + '&id=' + block.id
}
console.log('图床', ret)
return ret
}