-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into WV-46-fix-mixed-content-error
- Loading branch information
Showing
23 changed files
with
478 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const BASE_URL = process.env.NEXT_PUBLIC_API_KEY; | ||
|
||
// news-detail | ||
export const getNewsDetail = async ( | ||
artcSeq: string | ||
): Promise<ArticleContentsResponse["data"]> => { | ||
const queryparam = artcSeq ? `newsdetail?artcSeq=${artcSeq}` : ""; | ||
|
||
const url = `${BASE_URL}/article/${queryparam}`; | ||
const res = await fetch(url); | ||
|
||
if (!res.ok) { | ||
throw new Error("Failed to fetch news detail"); | ||
} | ||
|
||
const response: ArticleContentsResponse = await res.json(); | ||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type ArticleContentsResponse = { | ||
data: { | ||
article: ArticleContentsType; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { getNewsDetail } from "@/api/news/apis"; | ||
import { NewsDetail } from "@/components/media/news-detail"; | ||
|
||
export default async function page() { | ||
const { article } = await getNewsDetail("190048"); //임시 | ||
return <NewsDetail data={article} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
export default async function Page() { | ||
import { getPitcherDetail } from "@/api/player/apis"; | ||
import { PitcherDetail } from "@/components/player/pitcher/pitcher-detail"; | ||
|
||
export default async function Page({ | ||
params, | ||
}: { | ||
params: { | ||
pcode: string; | ||
}; | ||
}) { | ||
const { pcode } = params; | ||
const data = await getPitcherDetail(pcode); | ||
return ( | ||
<> | ||
<div>투수 디테일 페이지</div> | ||
{/* <CoachDetail /> */} | ||
<PitcherDetail data={data} /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { formatDate } from "date-fns"; | ||
import { CalendarDays, Eye } from "lucide-react"; | ||
|
||
export const NewsDetail = ({ data }: ArticleContentsProps) => { | ||
const formatContent = (htmlContent: string) => { | ||
const paragraphs = htmlContent | ||
.split(/<\/?p[^>]*>/) | ||
.filter((p) => p.trim().length > 0); | ||
|
||
const formattedParagraphs = paragraphs.map((p) => { | ||
if (p.includes("<img")) { | ||
return `<p style="text-align: center">${p}</p>`; | ||
} | ||
|
||
const textContent = p.replace(/<[^>]*>/g, "").trim(); | ||
if (textContent) { | ||
// 마침표와 느낌표를 기준으로 문장 나누기 | ||
const sentences = textContent | ||
.split(/[.!]/) // 정규식으로 .과 ! 모두를 구분자로 사용 | ||
.filter((s) => s.trim().length > 0) | ||
.map((s) => { | ||
const originalEnding = textContent.charAt( | ||
textContent.indexOf(s) + s.length | ||
); | ||
// 원래 문장의 마지막 부호(. 또는 !)를 유지 | ||
return `<p>${s.trim()}${originalEnding}</p>`; | ||
}) | ||
.join("\n"); | ||
return sentences; | ||
} | ||
return ""; | ||
}); | ||
|
||
return formattedParagraphs.join("\n"); | ||
}; | ||
|
||
return ( | ||
<div className="max-w-4xl mx-auto p-4"> | ||
<div className="flex justify-between items-center"> | ||
<h1 className="text-2xl font-bold mb-6 bg-SYSTEM-main/30"> | ||
{data.artcTitle} | ||
</h1> | ||
<div className="flex items-center gap-1 h-fit"> | ||
<CalendarDays className="text-ELSE-7374 w-6 h-6" /> | ||
<div className="text-ELSE-7374 "> | ||
{formatDate(data.regDttm, "yyyy.MM.dd")} | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
className="space-y-2" | ||
dangerouslySetInnerHTML={{ | ||
__html: formatContent(data.artcContents), | ||
}} | ||
/> | ||
<div className="flex gap-1 pt-1"> | ||
<Eye className="text-ELSE-7374 w-6 h-6" /> | ||
<div className="text-ELSE-7374"> 조회수 : {data.viewCnt}</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { PitcherStatsInfo } from "./pitcher-stats-info"; | ||
import { PitcherHistory } from "./pitcher-history"; | ||
import { PitcherProfileImage } from "./pitcher-profile-image"; | ||
|
||
export const PitcherDetail = ({ data }: PitcherDetailProps) => { | ||
return ( | ||
<div className="bg-SYSTEM-white rounded-lg shadow-lg overflow-hidden border"> | ||
<div className="grid md:grid-cols-2"> | ||
{/* 투수 프로필이미지 */} | ||
<PitcherProfileImage data={data} /> | ||
{/* 투수 스탯 */} | ||
<div className="p-8 space-y-6"> | ||
<PitcherStatsInfo data={data} /> | ||
{/* 투수 경기이력 및 커리어 */} | ||
<PitcherHistory data={data} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PitcherDetail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export const PitcherHistory = ({ data }: PitcherDetailProps) => { | ||
return ( | ||
<> | ||
<div className="border-t pt-4"> | ||
<h2 className="text-xl font-semibold mb-4">최근 경기 기록</h2> | ||
<div className="grid grid-cols-2 gap-6"> | ||
<div className="bg-SYSTEM-main/5 rounded-lg p-4 text-center"> | ||
<p className="text-sm text-ELSE-49">볼넷</p> | ||
<p className="text-2xl font-bold text-SYSTEM-main"> | ||
{data.seasonsummary.bb || "0"} | ||
</p> | ||
</div> | ||
<div className="bg-SYSTEM-main/5 rounded-lg p-4 text-center"> | ||
<p className="text-sm text-ELSE-49">삼진</p> | ||
<p className="text-2xl font-bold text-SYSTEM-main"> | ||
{data.seasonsummary.kk || "0"} | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{/* Career */} | ||
<div className="border-t pt-4"> | ||
<p className="text-ELSE-49">커리어</p> | ||
<p className="text-sm text-ELSE-49 mt-1"> | ||
{data.gameplayer.career || "-"} | ||
</p> | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Image from "next/image"; | ||
|
||
export const PitcherProfileImage = ({ data }: PitcherDetailProps) => { | ||
return ( | ||
<> | ||
<div className="flex items-center justify-center bg-SYSTEM-white"> | ||
<div | ||
className="relative w-full | ||
h-[300px] | ||
md:h-[450px] | ||
lg:h-[480px] | ||
xl:h-[540px] | ||
min-w-[280px] | ||
max-w-[540px] | ||
transition-all duration-300" | ||
> | ||
{data.gameplayer.playerPrvwImg ? ( | ||
<Image | ||
src={data.gameplayer.playerPrvwImg} | ||
alt={`${data.gameplayer.playerName} profile`} | ||
fill | ||
priority | ||
sizes="(max-width: 768px) 100vw, (max-width: 1024px) 450px, (max-width: 1280px) 480px, 540px" | ||
className="object-contain" | ||
/> | ||
) : ( | ||
<div className="w-full h-full flex items-center justify-center bg-ELSE-DE"> | ||
<p className="text-ELSE-7374">이미지 없음</p> | ||
</div> | ||
)} | ||
<div className="absolute top-0 left-2 bg-SYSTEM-white/90 rounded-full px-6 py-1 shadow-md z-10"> | ||
<span className="text-3xl font-bold text-SYSTEM-main"> | ||
# {data.gameplayer.backnum || "-"} | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.