Skip to content

Commit 18118dc

Browse files
👸
1 parent bb87181 commit 18118dc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pages/api/notion-page-info.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,25 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
4848
const isBlogPost =
4949
block.type === 'page' && block.parent_table === 'collection'
5050
const title = getBlockTitle(block, recordMap) || libConfig.name
51-
const image = mapImageUrl(
51+
let image = mapImageUrl(
5252
getPageProperty<string>('Social Image', block, recordMap) ||
5353
(block as PageBlock).format?.page_cover ||
5454
libConfig.defaultPageCover,
5555
block
5656
)
5757

58+
if (image) {
59+
const imageUrl = new URL(image)
60+
61+
if (imageUrl.host === 'images.unsplash.com') {
62+
if (!imageUrl.searchParams.has('w')) {
63+
imageUrl.searchParams.set('w', '2000')
64+
imageUrl.searchParams.set('fit', 'max')
65+
image = imageUrl.toString()
66+
}
67+
}
68+
}
69+
5870
const imageCoverPosition =
5971
(block as PageBlock).format?.page_cover_position ??
6072
libConfig.defaultPageCoverPosition

0 commit comments

Comments
 (0)