-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
아티클 상세 페이지에서 본문에 해당하는 내용을 서버로부터 가져옵니다. #132
아티클 상세 페이지에서 본문에 해당하는 내용을 서버로부터 가져옵니다. #132
Conversation
@@ -0,0 +1,56 @@ | |||
"use client"; | |||
|
|||
export function ArticleComment(): JSX.Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
개발 예정인 컴포넌트입니다. 차후 내용은 서버로 부터 가져와 채울 예정입니다.
<h2 id="introducing-ionic">Description</h2> | ||
<p>{article.description}</p> | ||
<h2 id="introducing-ionic">Main</h2> | ||
<p>{article.body.replace(/\\n/g, "\n")}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DB로부터 바로 가져오는지 \n과 같은 내용이 많았습니다. 개행을 하고 싶은건지 잘 모르겠어서 일단 지워줍니다.
export default async function ArticlePage(): Promise<JSX.Element> { | ||
const headersList = headers(); | ||
const activePath = headersList.get("x-invoke-path"); | ||
const slug = activePath?.split("/")[2]; | ||
|
||
if (!slug) { | ||
throw new Error("ERROR : article path is not found"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export default async function ArticlePage(): Promise<JSX.Element> { | |
const headersList = headers(); | |
const activePath = headersList.get("x-invoke-path"); | |
const slug = activePath?.split("/")[2]; | |
if (!slug) { | |
throw new Error("ERROR : article path is not found"); | |
} | |
type Params = { | |
slug: string; | |
} | |
type ArticlePageProps = { | |
params: Params; | |
} | |
export default async function ArticlePage({ params: { slug } }: ArticlePageProps): Promise<JSX.Element> { |
페이지 컴포넌트는 props를 통해 params에 접근할 수 있습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다 이건 몰랐네요 덕분에 간결하게 작성할 수 있었어요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📌 이슈 링크
📖 작업 배경
🛠️ 구현 내용
💡 참고사항
🖼️ 스크린샷