1- import  {  array ,  string  }  from  "prop-types" ; 
21import  {  Link  }  from  "gatsby" ; 
3- import  {  GatsbyImage  }  from  "gatsby-plugin-image" ; 
2+ import  {  GatsbyImage ,   type   IGatsbyImageData  }  from  "gatsby-plugin-image" ; 
43import  React  from  "react" ; 
54import  styled  from  "styled-components" ; 
65
@@ -36,7 +35,12 @@ const Item = styled.li`
3635    } 
3736  } 
3837` ; 
39- const  ItemImage  =  styled . div ` 
38+ 
39+ interface  ItemImageProps  { 
40+   readonly  $hasPlaceholder : boolean ; 
41+ } 
42+ 
43+ const  ItemImage  =  styled . div < ItemImageProps > ` 
4044  ${ setSpace ( "mbm" ) }  
4145  border: 2px solid ${ ( {  theme } )  =>  theme . actionColor }  
4246  position: relative; 
@@ -83,7 +87,14 @@ const ItemText = styled.p`
8387  ${ setSpace ( "mts" ) }  
8488` ; 
8589
86- function  Projects ( props )  { 
90+ interface  ProjectsProps  { 
91+   placeholder : IGatsbyImageData ; 
92+   projects : ProjectList ; 
93+   subtitle : string ; 
94+   title : string ; 
95+ } 
96+ 
97+ function  Projects ( props : ProjectsProps )  { 
8798  const  {  projects,  title,  subtitle }  =  props ; 
8899  return  ( 
89100    < Element  as = "section" > 
@@ -95,15 +106,22 @@ function Projects(props) {
95106        < Items > 
96107          { projects . map ( ( {  node } )  =>  { 
97108            const  project  =  node . frontmatter ; 
109+ 
110+             if  ( project  ===  null )  { 
111+               return  null ; 
112+             } 
113+ 
98114            return  ( 
99115              < Item  key = { node . id } > 
100116                < Tile  as = { Link }  to = { `/projects/${ project . uid }  } > 
101117                  < ItemImage  $hasPlaceholder = { ! project . cover } > 
102118                    < GatsbyImage 
103-                       image = { project . cover 
104-                         ? project . cover . childImageSharp . gatsbyImageData 
105-                         : props . placeholder } 
106-                       alt = { project . title } 
119+                       image = { 
120+                         project . cover ?. childImageSharp ?. gatsbyImageData 
121+                           ? project . cover . childImageSharp . gatsbyImageData 
122+                           : props . placeholder 
123+                       } 
124+                       alt = { project . title  ??  "" } 
107125                    /> 
108126                    { ! project . cover  ? ( 
109127                      < span  className = "thinking" > 
@@ -128,10 +146,4 @@ function Projects(props) {
128146  ) ; 
129147} 
130148
131- Projects . propTypes  =  { 
132-   projects : array . isRequired , 
133-   subtitle : string . isRequired , 
134-   title : string . isRequired 
135- } ; 
136- 
137149export  default  Projects ; 
0 commit comments