@@ -6,32 +6,34 @@ export default function ArticlePreview({
66 date,
77 excerpt,
88 slug,
9- tags,
9+ tags = [ ] ,
1010 title,
1111} ) {
12+ if ( ! slug || ! title ) return null
13+
1214 return (
1315 < div className = "px-6 flex flex-col items-start" >
1416 < Link as = { `/articles/${ slug } ` } href = "/articles/[slug]" >
1517 < a className = "sm:text-3xl text-2xl title-font font-medium text-gray-900 mt-4 mb-4" > { title } </ a >
1618 </ Link >
1719 < div className = "inline-flex" >
18- < div className = "text-lg font-bold text-gray-400 mr-6" >
19- < DateFormatter dateString = { date } / >
20- </ div >
21- < div >
22- < Tags key = { slug } tags = { tags } />
23- </ div >
20+ { date && (
21+ < div className = "text-lg font-bold text-gray-400 mr-6" >
22+ < DateFormatter dateString = { date } / >
23+ </ div >
24+ ) }
25+ < Tags tags = { tags } / >
2426 </ div >
25- < p className = "leading-relaxed mt-4 mb-4" > { excerpt } </ p >
27+ { excerpt && < p className = "leading-relaxed mt-4 mb-4" > { excerpt } </ p > }
2628 < div className = "flex items-center flex-wrap pb-4 mb-4 border-b-2 border-gray-100 mt-auto w-full" >
27- < Link as = { `/articles/${ slug } ` } href = "/articles/[slug]" >
28- < a className = "text-red-500 font-bold hover:underline hover:text-red-600 inline-flex items-center" > Learn More
29- < svg className = "w-4 h-4 ml-2" viewBox = "0 0 24 24" stroke = "currentColor" strokeWidth = "4" fill = "none" strokeLinecap = "round" strokeLinejoin = "round" >
30- < path d = "M5 12h14" > </ path >
31- < path d = "M12 5l7 7-7 7" > </ path >
32- </ svg >
33- </ a >
34- </ Link >
29+ < Link as = { `/articles/${ slug } ` } href = "/articles/[slug]" >
30+ < a className = "text-red-500 font-bold hover:underline hover:text-red-600 inline-flex items-center" > Learn More
31+ < svg className = "w-4 h-4 ml-2" viewBox = "0 0 24 24" stroke = "currentColor" strokeWidth = "4" fill = "none" strokeLinecap = "round" strokeLinejoin = "round" >
32+ < path d = "M5 12h14" > </ path >
33+ < path d = "M12 5l7 7-7 7" > </ path >
34+ </ svg >
35+ </ a >
36+ </ Link >
3537 </ div >
3638 </ div >
3739 )
0 commit comments