Skip to content

Commit 78faf94

Browse files
committed
applied codex suggestions
1 parent 0ce7747 commit 78faf94

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/Sanity/Blocks/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ const PageBlocks: React.FC<Props> = ({ page }) => {
3636
const { asset, _key: imageKey } = childElement;
3737
const width = asset?.metadata?.dimensions?.width ?? 800;
3838
const height = asset?.metadata?.dimensions?.height ?? 600;
39+
const imageUrl = getImageUrl(asset);
40+
if (!imageUrl) {
41+
return;
42+
}
3943
elementBlocks.push(
4044
<div
4145
key={`${bodyElementKey}-${childElementKey}-${imageKey}`}
4246
className={styles.imageContainer}
4347
>
4448
<Image
4549
className={styles.image}
46-
src={getImageUrl(asset)}
50+
src={imageUrl}
4751
alt=""
4852
width={width}
4953
height={height}

src/components/Sanity/Page/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const Page: React.FC<Props> = ({ page, isIndividualPage = false }) => {
2727
year: 'numeric',
2828
});
2929
const pageTitle = <p className={classNames(styles.title, styles.bold)}>{page.title}</p>;
30+
const imageUrl = page.mainPhoto ? getImageUrl(page.mainPhoto) : '';
3031
return (
3132
<div key={page.id} className={styles.pageContainer}>
3233
<div className={styles.headerSection}>
@@ -56,11 +57,11 @@ const Page: React.FC<Props> = ({ page, isIndividualPage = false }) => {
5657
{pageTitle}
5758
</Link>
5859
{page.summary}
59-
{page.mainPhoto && (
60+
{page.mainPhoto && imageUrl && (
6061
<div className={styles.imageContainer}>
6162
<Image
6263
className={styles.image}
63-
src={getImageUrl(page.mainPhoto)}
64+
src={imageUrl}
6465
alt=""
6566
width={page.mainPhoto?.metadata?.dimensions?.width ?? 800}
6667
height={page.mainPhoto?.metadata?.dimensions?.height ?? 600}

0 commit comments

Comments
 (0)