Fix crash for card cover defined without objectFit (#3683)

This commit is contained in:
Samy Pessé
2025-09-24 11:01:06 +02:00
committed by GitHub
parent c21693fe50
commit c23d4ef331
2 changed files with 11 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Fix crash for card cover defined without objectFit
@@ -71,16 +71,18 @@ function processCoverValue(value: DocumentTableImageRecord | string[] | null | u
}
}
const imageValue = value as DocumentTableImageRecord | null | undefined;
// Check if it's the new schema with objectFit
if (value && typeof value === 'object' && 'ref' in value && 'objectFit' in value) {
if (imageValue && typeof imageValue === 'object' && 'ref' in imageValue) {
return {
contentRef: value.ref,
objectFit: value.objectFit,
contentRef: imageValue.ref,
objectFit: imageValue.objectFit,
};
}
// It's a direct ContentRef
return { contentRef: value as ContentRefFile | ContentRefURL };
return { contentRef: imageValue || null };
}
/**