From 18118dc2437097b6ba5f67858bfc4f6b83665e59 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sat, 15 Oct 2022 00:15:51 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/api/notion-page-info.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pages/api/notion-page-info.tsx b/pages/api/notion-page-info.tsx index 2e7e31d..a76587d 100644 --- a/pages/api/notion-page-info.tsx +++ b/pages/api/notion-page-info.tsx @@ -48,13 +48,25 @@ export default async (req: NextApiRequest, res: NextApiResponse) => { const isBlogPost = block.type === 'page' && block.parent_table === 'collection' const title = getBlockTitle(block, recordMap) || libConfig.name - const image = mapImageUrl( + let image = mapImageUrl( getPageProperty('Social Image', block, recordMap) || (block as PageBlock).format?.page_cover || libConfig.defaultPageCover, block ) + if (image) { + const imageUrl = new URL(image) + + if (imageUrl.host === 'images.unsplash.com') { + if (!imageUrl.searchParams.has('w')) { + imageUrl.searchParams.set('w', '2000') + imageUrl.searchParams.set('fit', 'max') + image = imageUrl.toString() + } + } + } + const imageCoverPosition = (block as PageBlock).format?.page_cover_position ?? libConfig.defaultPageCoverPosition