@@ -6,7 +6,7 @@ import { Image } from "astro:assets";
66
77interface Props {
88 variant? : " normal" | " compact" ;
9- articles: ( Article & { body: string }) [];
9+ articles: { data : Article ; body? : string }[];
1010 class? : string ;
1111}
1212const props = Astro .props ;
@@ -53,17 +53,17 @@ const { variant = "normal", articles } = props;
5353 ? {
5454 cellClassName: " md:col-span-2 md:row-span-2" ,
5555 imageClassName: " h-[350px] md:h-[450px]" ,
56- excerpt: article .body .slice (0 , 120 ),
56+ excerpt: article .body ? .slice (0 , 120 ),
5757 }
5858 : {
5959 cellClassName: " " ,
6060 imageClassName: " h-[200px]" ,
61- excerpt: article .body .slice (0 , 120 ),
61+ excerpt: article .body ? .slice (0 , 120 ),
6262 };
6363 return (
6464 <li class = " contents" >
6565 <a
66- href = { ` /articles/${article .slug } ` }
66+ href = { ` /articles/${article .data . slug } ` }
6767 class :list = { [
6868 " block hover:opacity-80" ,
6969 additionalProps .cellClassName ,
@@ -75,27 +75,19 @@ const { variant = "normal", articles } = props;
7575 additionalProps .imageClassName ,
7676 ]}
7777 >
78- { article .image ? (
79- <Image
80- alt = " カバー画像"
81- height = { 48 * 4 * 4 }
82- width = { 48 * 4 * 4 }
83- src = { article .image }
84- class = " w-full h-full object-cover"
85- />
86- ) : (
87- <img
88- alt = " 画像なし"
89- src = { noImage .src }
90- class = " w-full h-full object-cover"
91- />
92- )}
78+ <Image
79+ alt = " カバー画像"
80+ height = { 48 * 4 * 4 }
81+ width = { 48 * 4 * 4 }
82+ src = { article .data .image }
83+ class = " w-full h-full object-cover"
84+ />
9385 </div >
9486 <div class = " mt-4" >
9587 <time class = " block text-gray-500 text-sm" >
96- { format (article .date , " yyyy/MM/dd HH:mm" )}
88+ { format (article .data . date , " yyyy/MM/dd HH:mm" )}
9789 </time >
98- <h3 class = " text-lg font-bold" >{ article .title } </h3 >
90+ <h3 class = " text-lg font-bold" >{ article .data . title } </h3 >
9991 <p class = " prose max-w-none mt-2" >{ additionalProps .excerpt } </p >
10092 </div >
10193 </a >
@@ -104,5 +96,3 @@ const { variant = "normal", articles } = props;
10496 })
10597 }
10698</ul >
107- ); }
108-
0 commit comments