Skip to content

Commit 768173b

Browse files
committed
feat: 첫img에 fetchPriority="high" 적용
1 parent fbfb178 commit 768173b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/features/home/ui/PostCardList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ const PostCardList = ({ selectedTab }: PostCardListProps) => {
5252
return (
5353
<>
5454
<ul className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4">
55-
{posts.map((item: CardItemProps) => {
55+
{posts.map((item: CardItemProps, index: number) => {
5656
const postId = item.postId ?? item.id;
57-
return <CardItem key={postId} {...item} id={postId} />;
57+
return <CardItem key={postId} {...item} id={postId} priority={index === 0 && selectedTab === 0} />;
5858
})}
5959
</ul>
6060
{activeQuery?.isFetchingNextPage && <Loading />}

src/shared/ui/CardItem.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface CardItemProps {
2424
viewCount: number;
2525
keywords?: string[];
2626
shortSummary: string;
27+
priority?: boolean;
2728
}
2829

2930
export const CardItem = forwardRef<HTMLLIElement, CardItemProps>(
@@ -39,6 +40,7 @@ export const CardItem = forwardRef<HTMLLIElement, CardItemProps>(
3940
publishedAt,
4041
isBookmarked,
4142
shortSummary,
43+
priority = false,
4244
},
4345
ref,
4446
) => {
@@ -116,8 +118,7 @@ export const CardItem = forwardRef<HTMLLIElement, CardItemProps>(
116118
src={thumbnailUrl}
117119
alt={`{${title} - 썸네일}`}
118120
className=" w-full h-full object-cover"
119-
// loading="lazy"
120-
// decoding="async"
121+
fetchPriority={priority ? "high" : "auto"}
121122
/>
122123
) : (
123124
<p className="line-clamp-9 overflow-hidden text-clip min-h-45 text-sm">

0 commit comments

Comments
 (0)