@@ -12,6 +12,7 @@ import PostsCards from '@/components/PostsCards';
1212import { GetStaticPaths , GetStaticProps , InferGetStaticPropsType } from 'next' ;
1313import { Sponsor } from '@/models/sponsor.model' ;
1414import Image from 'next/image' ;
15+ import DefaultErrorPage from 'next/error' ;
1516
1617interface StaticParams {
1718 site : Site ;
@@ -78,6 +79,13 @@ export default function SponsorPage({
7879 sponsor,
7980 podcasts,
8081} : InferGetStaticPropsType < typeof getStaticProps > ) {
82+ if ( ! sponsor ) {
83+ return (
84+ < Layout site = { site } >
85+ < DefaultErrorPage statusCode = { 404 } />
86+ </ Layout >
87+ ) ;
88+ }
8189 return (
8290 < >
8391 < NextSeo
@@ -86,7 +94,7 @@ export default function SponsorPage({
8694 > </ NextSeo >
8795 < Layout site = { site } >
8896 < section className = "grid grid-cols-1 gap-20 p-4 sm:p-10 place-items-center" >
89- < a href = { sponsor . url } rel = "noreferrer noopener" target = "_blank" >
97+ < a href = { sponsor ? .url } rel = "noreferrer noopener" target = "_blank" >
9098 < article className = "grid items-start grid-cols-1 gap-4 shadow-lg rounded-xl justify-items-center justify-self-center hover:shadow-sm" >
9199 < div className = "w-full rounded-lg shadow-lg bg-primary-100 dark:bg-primary-500" >
92100 < div className = "p-2" >
@@ -102,7 +110,7 @@ export default function SponsorPage({
102110 < div className = "absolute inset-0 flex flex-col items-center justify-center p-2" >
103111 { sponsor ?. coverPhoto ?. public_id && (
104112 < Image
105- src = { sponsor . coverPhoto . public_id }
113+ src = { sponsor ? .coverPhoto . public_id }
106114 alt = { `Sponsorship Image for ${ sponsor . company } ` }
107115 layout = "fill"
108116 />
0 commit comments