Skip to content

Commit c23d4ef

Browse files
authored
Fix crash for card cover defined without objectFit (#3683)
1 parent c21693f commit c23d4ef

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.changeset/shiny-onions-guess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Fix crash for card cover defined without objectFit

packages/gitbook/src/components/DocumentView/Table/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,18 @@ function processCoverValue(value: DocumentTableImageRecord | string[] | null | u
7171
}
7272
}
7373

74+
const imageValue = value as DocumentTableImageRecord | null | undefined;
75+
7476
// Check if it's the new schema with objectFit
75-
if (value && typeof value === 'object' && 'ref' in value && 'objectFit' in value) {
77+
if (imageValue && typeof imageValue === 'object' && 'ref' in imageValue) {
7678
return {
77-
contentRef: value.ref,
78-
objectFit: value.objectFit,
79+
contentRef: imageValue.ref,
80+
objectFit: imageValue.objectFit,
7981
};
8082
}
8183

8284
// It's a direct ContentRef
83-
return { contentRef: value as ContentRefFile | ContentRefURL };
85+
return { contentRef: imageValue || null };
8486
}
8587

8688
/**

0 commit comments

Comments
 (0)