Skip to content

Commit bf7435d

Browse files
committed
Fix type errors
1 parent 12432f8 commit bf7435d

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

src/api/OpenProcessing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export type OpenProcessingSketchResponse = {
6464
userID: string;
6565
submittedOn: string;
6666
createdOn: string;
67+
mode: string;
6768
};
6869

6970
/**

src/components/GridItem/Sketch.astro

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
thumbnailDimensions,
66
type OpenProcessingCurationResponse,
77
} from "@/src/api/OpenProcessing";
8+
import isString from "lodash/isstring"
89
910
interface Props {
1011
item: OpenProcessingCurationResponse[number];
@@ -16,7 +17,7 @@ const { item, lazyLoad, scale = 1 } = Astro.props;
1617
const imgSrc = await getSketchThumbnailSource(item.visualID)
1718
const width = Math.min(thumbnailDimensions * scale, 1500);
1819
const height = Math.min(
19-
(imgSrc.width && imgSrc.height ? imgSrc.height / imgSrc.width : 1) * thumbnailDimensions * scale,
20+
(isString(imgSrc) ? 1 : imgSrc.height / imgSrc.width) * thumbnailDimensions * scale,
2021
1000,
2122
);
2223
---
@@ -30,13 +31,22 @@ const height = Math.min(
3031
// the thumbnail looks like, and the OpenProcessing API
3132
// doesn't include that information
3233
}
33-
<Image
34-
src={imgSrc}
35-
alt="Screenshot of sketch"
36-
width={width}
37-
height={scale}
38-
loading={lazyLoad ? "lazy" : "eager"}
39-
/>
34+
{isString(imgSrc) ? (
35+
<img
36+
src={imgSrc as any}
37+
alt="Screenshot of sketch"
38+
width={width}
39+
height={height}
40+
/>
41+
) : (
42+
<Image
43+
src={imgSrc}
44+
alt="Screenshot of sketch"
45+
width={width}
46+
height={height}
47+
loading={lazyLoad ? "lazy" : "eager"}
48+
/>
49+
)}
4050
<p
4151
class="text-body mt-xs text-wrap break-words break-keep group-hover:underline"
4252
>

0 commit comments

Comments
 (0)