diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 0dae6ab9..ea30fbfc 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -7,11 +7,14 @@ import BLOG from '@/blog.config' * @param {*} image */ const compressImage = (image, width = 400) => { - if (image && image.indexOf(BLOG.NOTION_HOST) === 0) { + if (!image) { + return null + } + if (image.indexOf(BLOG.NOTION_HOST) === 0) { return `${image}&width=${width}` } // 压缩unsplash图片 - if (image && image.indexOf('https://images.unsplash.com/') === 0) { + if (image.indexOf('https://images.unsplash.com/') === 0) { // 将URL解析为一个对象 const urlObj = new URL(image) // 获取URL参数 @@ -27,6 +30,12 @@ const compressImage = (image, width = 400) => { return urlObj.toString() } + // 此处还可以添加您的自定义图传的封面图压缩参数。 + // .e.g + if (image.indexOf('https://your_picture_bed') === 0) { + return 'do_somethin_here' + } + return image }