From ef618743482bb477d2ada6aa84432cc096ef8270 Mon Sep 17 00:00:00 2001 From: Chaeyeon1 <66813821+Chaeyeon1@users.noreply.github.com> Date: Thu, 14 Dec 2023 18:32:03 +0900 Subject: [PATCH] =?UTF-8?q?#161=20data=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/[categoryId]/[postId]/page.tsx | 42 +++++++------------ 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx b/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx index 723e4a9..de8d3fa 100644 --- a/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx +++ b/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx @@ -1,39 +1,29 @@ import PostData from '@/components/Post/PostData'; -// import { SERVER_URL } from '@/constant/common'; +import { SERVER_URL } from '@/constant/common'; import { Metadata } from 'next'; import React from 'react'; -// const getData = async (id: number) => { -// const res = await fetch(`${SERVER_URL}/post?postId=${id}`); -// return res.json(); -// }; +const getData = async (id: number) => { + const res = await fetch(`${SERVER_URL}/post?postId=${id}`); + return res.json(); +}; + +export const generateMetadata = async ({ + params, +}: { + params: { id: string }; +}): Promise => { + const data = await getData(Number(params.id)); -export const generateMetadata = async (): Promise => { return { - title: '타이틀입니다.', - description: 'ㅁㄴㅇㄹ', + title: data.title, + description: data.content, openGraph: { - title: 'openGraph 타이틀이빈다.', - description: 'ㅁㄴㅇㄹ', + title: data.title, + description: data.content, }, }; }; -// export const generateMetadata = async ({ -// params, -// }: { -// params: { id: string }; -// }): Promise => { -// const data = await getData(Number(params.id)); - -// return { -// title: '타이틀입니다.', -// description: 'ㅁㄴㅇㄹ', -// openGraph: { -// title: 'openGraph 타이틀이빈다.', -// description: 'ㅁㄴㅇㄹ', -// }, -// }; -// }; function page({ params }: { params: { blogName: string; categoryId: string; postId: string } }) { return (