Skip to content

Commit 747cf28

Browse files
authored
Merge pull request #224 from manNomi/refactor/home-head
Refactor/home head
2 parents 7640eaa + 309f351 commit 747cf28

12 files changed

Lines changed: 53 additions & 35 deletions

File tree

File renamed without changes.
File renamed without changes.

src/app/_home/_ui/PopularUniversitySection/_hooks/useWheelHandler.ts renamed to src/app/(home)/_ui/PopularUniversitySection/_hooks/useWheelHandler.ts

File renamed without changes.
File renamed without changes.

src/app/_home/_ui/UniversityList/_hooks/useRegionHandler.ts renamed to src/app/(home)/_ui/UniversityList/_hooks/useRegionHandler.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/app/(home)/head.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import getRecommendedUniversity from "@/api/university/server/getRecommendedUniversity";
2+
import { fetchAllNews } from "@/lib/firebaseNews";
3+
4+
const Head = async () => {
5+
const newsList = await fetchAllNews();
6+
const { data } = await getRecommendedUniversity();
7+
const recommendedColleges = data?.recommendedUniversities || [];
8+
9+
// ─── LCP 이미지 Preload ───
10+
const lcpImage =
11+
recommendedColleges.length > 0 && recommendedColleges[0].backgroundImageUrl
12+
? `${process.env.NEXT_PUBLIC_IMAGE_URL}/${recommendedColleges[0].backgroundImageUrl}`
13+
: "/images/default-university.jpg";
14+
15+
const preloadLink = <link rel="preload" as="image" href={lcpImage} fetchPriority="high" />;
16+
17+
/** ───── JSON‑LD 구조화 데이터 ───── */
18+
const structuredData =
19+
newsList.length === 0
20+
? null
21+
: {
22+
"@context": "https://schema.org",
23+
"@type": "ItemList",
24+
itemListElement: newsList.slice(0, 3).map((n, idx) => ({
25+
"@type": "NewsArticle",
26+
position: idx + 1,
27+
headline: n.title,
28+
description: n.description,
29+
url: n.url,
30+
image: n.imageUrl,
31+
})),
32+
};
33+
34+
return (
35+
<>
36+
{/* LCP 이미지 Preload */}
37+
{preloadLink}
38+
39+
{/* JSON‑LD (뉴스 3개) */}
40+
{structuredData && (
41+
<script
42+
id="ld-json-homepage"
43+
type="application/ld+json"
44+
dangerouslySetInnerHTML={{
45+
__html: JSON.stringify(structuredData),
46+
}}
47+
/>
48+
)}
49+
</>
50+
);
51+
};
52+
export default Head;

0 commit comments

Comments
 (0)