Skip to content

Commit c8b4422

Browse files
authored
Merge pull request NotionX#430 from NotionX/fix-new-image-src-error
Hot fix - new image src with file.notion.so not working
2 parents 3aef81f + 130d0c3 commit c8b4422

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/notion-utils/src/get-page-image-urls.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export const getPageImageUrls = (
2323
if (block) {
2424
if (block.type === 'image') {
2525
const signedUrl = recordMap.signed_urls?.[block.id]
26-
const source = signedUrl || block.properties?.source?.[0]?.[0]
26+
let source = signedUrl || block.properties?.source?.[0]?.[0]
27+
if (source.includes('file.notion.so')) {
28+
source = block.properties?.source?.[0]?.[0]
29+
}
2730

2831
if (source) {
2932
images.push({

packages/react-notion-x/src/components/asset.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const Asset: React.FC<{
124124
}
125125
}
126126

127-
const source =
127+
let source =
128128
recordMap.signed_urls?.[block.id] || block.properties?.source?.[0]?.[0]
129129
let content = null
130130

@@ -258,7 +258,10 @@ export const Asset: React.FC<{
258258
}
259259
} else if (block.type === 'image') {
260260
// console.log('image', block)
261-
261+
//kind of a hack for now. New file.notion.so images aren't signed correctly
262+
if (source.includes('file.notion.so')) {
263+
source = block.properties?.source?.[0]?.[0]
264+
}
262265
const src = mapImageUrl(source, block as Block)
263266
const caption = getTextContent(block.properties?.caption)
264267
const alt = caption || 'notion image'

0 commit comments

Comments
 (0)