File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ export interface NewsletterProps {
1919 subtitle : string
2020 summary : string
2121 postUrl : string
22- imageUrl : string
23- imageAlt : string
22+ imageUrl ? : string
23+ imageAlt ? : string
2424}
2525
2626Newsletter . PreviewProps = {
@@ -57,11 +57,13 @@ export default function Newsletter(props: Readonly<NewsletterProps>) {
5757 style = { container }
5858 >
5959 < Section className = "my-[16px]" >
60- < Img
61- className = "w-full rounded-xl object-cover"
62- src = { props . imageUrl }
63- alt = { props . imageAlt }
64- />
60+ { props . imageUrl && (
61+ < Img
62+ className = "w-full rounded-xl object-cover"
63+ src = { props . imageUrl }
64+ alt = { props . imageAlt }
65+ />
66+ ) }
6567 < Section className = "mt-[32px] text-center" >
6668 < Text
6769 className = "my-[16px] text-[18px] font-semibold leading-[28px]"
Original file line number Diff line number Diff line change @@ -68,14 +68,18 @@ function getLatestPost(rootPath: string): NewsletterProps {
6868 content . indexOf ( "\n" , content . indexOf ( "\n" ) + 1 )
6969 )
7070
71- return {
71+ const post : NewsletterProps = {
7272 title : data . title ,
7373 subtitle : data . description ,
7474 summary,
7575 postUrl : permalink . toString ( ) ,
76- imageUrl : buildImageURL ( slug , data . feature ) . toString ( ) ,
77- imageAlt : data . featureAlt ,
7876 }
77+ if ( data . feature ) {
78+ post . imageUrl = buildImageURL ( slug , data . feature ) . toString ( )
79+ post . imageAlt = data . featureAlt
80+ }
81+
82+ return post
7983}
8084
8185function buildImageURL ( postSlug : string , imageSlug : string ) : URL {
You can’t perform that action at this time.
0 commit comments