Skip to content

Commit

Permalink
fix: fix build failing due to undefine iscreenshot in project detail
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSuperDev committed Aug 2, 2022
1 parent 2dfa254 commit d133767
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 32 deletions.
6 changes: 3 additions & 3 deletions data/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export interface ProjectScope {
}

export interface ProjectScreenshot {
url: string;
width: number;
height: number;
url?: string;
width?: number;
height?: number;
}

export interface Link {
Expand Down
18 changes: 10 additions & 8 deletions src/pages/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ function ProjectItemCompact({ project }: { project: Project }) {
className='grid grid-cols-1 gap-4 p-5 md:grid-cols-3 '
>
<div className='mx-auto w-36'>
<Image
src={project.screenshots.logo.url}
alt={project.name}
layout='responsive'
width={150}
height={150}
objectFit='contain'
/>
{project.screenshots.logo.url && (
<Image
src={project.screenshots.logo.url}
alt={project.name}
layout='responsive'
width={150}
height={150}
objectFit='contain'
/>
)}
</div>
<div className='md:col-span-2'>
<h3 className='prose prose-xl dark:prose-invert'>{project.name}</h3>
Expand Down
18 changes: 11 additions & 7 deletions src/pages/projects/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ const ProjectDetail = ({ projectDetail }: { projectDetail: Project }) => {
<div className='mx-auto flex flex-row flex-wrap'>
<div className='mx-auto flex flex-grow basis-full'>
<div className='aspect-w-16 aspect-h-9 mx-auto w-full max-w-5xl rounded-b-none lg:rounded-b-lg'>
<Image
alt={title}
src={screenshots.webScreenshot.url}
layout='fill'
objectFit='cover'
className='rounded-lg group-hover:opacity-75'
/>
{screenshots?.webScreenshot?.url ? (
<Image
alt={title}
src={screenshots.webScreenshot.url}
layout='fill'
objectFit='cover'
className='rounded-lg group-hover:opacity-75'
/>
) : (
<div> </div>
)}
</div>
</div>
</div>
Expand Down
32 changes: 18 additions & 14 deletions src/pages/projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ export function ProjectListItem({
<div className='mx-auto grid w-full grid-cols-1 gap-4 py-7 dark:bg-transparent md:grid-cols-3 lg:grid-cols-4'>
<div className='mx-auto w-full items-center px-4 text-center'>
<figure>
<Image
src={screenshots.logo.url}
alt={`${name} logo`}
className='rounded-xl'
width={300}
height={300}
/>
{screenshots.logo.url && (
<Image
src={screenshots.logo.url}
alt={`${name} logo`}
className='rounded-xl'
width={300}
height={300}
/>
)}
</figure>
<p className='break-word px-7 text-center'>{subTitle}</p>
</div>
Expand Down Expand Up @@ -147,13 +149,15 @@ export function ProjectGridItem({
key={id}
>
<figure className='px-10 pt-10'>
<Image
src={screenshots.logo.url}
alt={`${name} logo`}
className='rounded-xl'
width={300}
height={300}
/>
{screenshots.logo.url && (
<Image
src={screenshots.logo.url}
alt={`${name} logo`}
className='rounded-xl'
width={300}
height={300}
/>
)}
</figure>
<div className='card-body items-center text-center'>
<h2 className='card-title'>{title}</h2>
Expand Down

0 comments on commit d133767

Please sign in to comment.