@@ -14,28 +14,35 @@ import newsIcon from '/public/gfx/news-paper-icon-black.svg';
14
14
import style from './PressNewsItem.module.scss' ;
15
15
16
16
type Props = {
17
- newsItem : ContentProps ;
17
+ newsItem : Pick <
18
+ ContentProps ,
19
+ 'language' | 'type' | 'data' | '_path' | 'displayName' | 'publish' | 'createdTime'
20
+ > ;
18
21
} ;
19
22
23
+ function hasContentType ( data : any ) : data is { contentType : string } {
24
+ return data && typeof data . contentType === 'string' ;
25
+ }
26
+
20
27
export const PressNewsItem = ( { newsItem } : Props ) => {
21
28
const { language } = newsItem ;
22
29
const getTranslations = translator ( 'pressLanding' , language ) ;
23
30
24
- const getTaglineElements = ( newsItem : ContentProps ) => {
31
+ const getTaglineElements = ( { newsItem } : Props ) => {
25
32
if ( newsItem . type === ContentType . MainArticle ) {
26
- const isNews = newsItem . data . contentType === 'news' ;
33
+ const isNews = hasContentType ( newsItem . data ) && newsItem . data . contentType === 'news' ;
27
34
const icon = isNews ? newsIcon : pressIcon ;
28
35
const tagName = getTranslations ( isNews ? 'news' : 'press' ) ;
29
36
return { icon, tagName } ;
30
37
}
31
38
return { icon : null , tagName : null } ;
32
39
} ;
33
40
34
- const { icon, tagName } = getTaglineElements ( newsItem ) ;
41
+ const { icon, tagName } = getTaglineElements ( { newsItem } ) ;
35
42
36
43
return (
37
44
< li key = { newsItem . _path } className = { style . newsItem } >
38
- < LenkeBase href = { getPublicPathname ( newsItem ) } >
45
+ < LenkeBase href = { getPublicPathname ( { _path : newsItem . _path } ) } >
39
46
< Heading level = { '3' } size = { 'medium' } >
40
47
{ newsItem . displayName }
41
48
</ Heading >
0 commit comments