11import Image from "next/image" ;
22import Link from "next/link" ;
3+ import { Suspense } from "react" ;
34
45import { ListUniversity } from "@/types/university" ;
56
@@ -8,10 +9,14 @@ type PopularUniversitySectionProps = {
89} ;
910
1011const PopularUniversitySection = ( { universities } : PopularUniversitySectionProps ) => {
12+ const aboveFold = universities . slice ( 0 , 3 ) ;
13+ const belowFold = universities . slice ( 3 ) ;
14+
1115 return (
1216 < div className = "overflow-x-auto" >
1317 < div className = "flex gap-2" >
14- { universities . map ( ( university , index ) => (
18+ { /* 첫 4장은 즉시 전송 – LCP 후보 */ }
19+ { aboveFold . map ( ( university , index ) => (
1520 < Link key = { university . id } href = { `/university/${ university . id } ` } >
1621 < div className = "relative w-[153px]" >
1722 < div className = "relative w-[153px]" >
@@ -25,9 +30,9 @@ const PopularUniversitySection = ({ universities }: PopularUniversitySectionProp
2530 width = { 153 }
2631 height = { 120 }
2732 alt = { `${ university . koreanName || "대학교" } 배경 이미지` }
28- priority = { index < 3 } // 상위 3개는 우선 로딩
29- loading = { index >= 3 ? "lazy " : "eager " }
30- fetchPriority = { index === 0 ? "high" : index < 3 ? "high" : "auto "}
33+ priority = { index === 0 } // 첫 카드만 LCP 후보
34+ loading = { index === 0 ? "eager " : "lazy " }
35+ fetchPriority = { index === 0 ? "high" : "low "}
3136 sizes = "153px"
3237 unoptimized = { false }
3338 />
@@ -38,9 +43,50 @@ const PopularUniversitySection = ({ universities }: PopularUniversitySectionProp
3843 </ div >
3944 </ Link >
4045 ) ) }
46+
47+ { /* 나머지는 뒤늦게 HTML 스트림으로 전송 */ }
48+ { belowFold . length > 0 && (
49+ < Suspense fallback = { null } >
50+ < PopularUniversitiesBelowFold universities = { belowFold } />
51+ </ Suspense >
52+ ) }
4153 </ div >
4254 </ div >
4355 ) ;
4456} ;
4557
58+ const PopularUniversitiesBelowFold = ( { universities } : { universities : ListUniversity [ ] } ) => {
59+ return (
60+ < >
61+ { universities . map ( ( university ) => (
62+ < Link key = { university . id } href = { `/university/${ university . id } ` } >
63+ < div className = "relative w-[153px]" >
64+ < div className = "relative w-[153px]" >
65+ < Image
66+ className = "h-[120px] rounded-lg object-cover"
67+ src = {
68+ university . backgroundImageUrl
69+ ? `${ process . env . NEXT_PUBLIC_IMAGE_URL } /${ university . backgroundImageUrl } `
70+ : "/images/default-university.jpg"
71+ }
72+ width = { 153 }
73+ height = { 120 }
74+ alt = { `${ university . koreanName || "대학교" } 배경 이미지` }
75+ priority = { false }
76+ loading = "lazy"
77+ fetchPriority = "low"
78+ sizes = "153px"
79+ unoptimized = { false }
80+ />
81+ </ div >
82+ < div className = "absolute bottom-[9px] left-[10px] z-10 text-sm font-semibold leading-[160%] tracking-[0.15px] text-white" >
83+ { university . koreanName }
84+ </ div >
85+ </ div >
86+ </ Link >
87+ ) ) }
88+ </ >
89+ ) ;
90+ } ;
91+
4692export default PopularUniversitySection ;
0 commit comments