Skip to content

Commit

Permalink
Fix: Ignore empty CMS entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Haliax committed Feb 10, 2024
1 parent 3ef8d27 commit 3583f28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion components/blocks/mediaBlock/MediaBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ const WideMediaBlock = (url: string, effects: Array<'blur' | 'grayscale' | 'desa
);
};

// eslint-disable-next-line complexity
const MediaBlock = ({ media, caption = '', size, effects }: MediaBlockProps): ReactElement | null => {

if (typeof media === 'string') {
return null;
}

if (isEmptyString(media.url)) {
if (media.url === undefined || media.url === null || isEmptyString(media.url)) {
return null;
}

Expand Down
12 changes: 8 additions & 4 deletions pages/events/history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@ export default ({ events, page }: Props): ReactElement => {
initialData: page,
});

const media = pageData.headerImage as Media | undefined;

return (
<div className="min-h-screen flex flex-col justify-between">
<HeaderBar />
<ContentDivider />

<main id="content">
<MediaBlock
size="wide"
media={pageData.headerImage as Media}
/>
{media !== undefined && media.url !== undefined && (
<MediaBlock
size="wide"
media={pageData.headerImage as Media}
/>
)}
<HeadlineBlock
title={pageData.title}
level="h1"
Expand Down

0 comments on commit 3583f28

Please sign in to comment.