From 8ef59b931cf60cd3c695673914b8408d06a6e0d4 Mon Sep 17 00:00:00 2001 From: yujinimda Date: Thu, 2 Apr 2026 00:02:35 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[Day16]=20=E2=96=B2=20Next.js=EC=97=90?= =?UTF-8?q?=EC=84=9C=20generateMetadata=EB=A1=9C=20=EB=8F=99=EC=A0=81=20SE?= =?UTF-8?q?O=20=EA=B5=AC=ED=98=84=ED=95=98=EA=B8=B0=20-=20=EB=B0=95?= =?UTF-8?q?=EC=9C=A0=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\225\354\234\240\354\247\204.ts" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "problems/day16/\353\260\225\354\234\240\354\247\204.ts" diff --git "a/problems/day16/\353\260\225\354\234\240\354\247\204.ts" "b/problems/day16/\353\260\225\354\234\240\354\247\204.ts" new file mode 100644 index 0000000..f158ee0 --- /dev/null +++ "b/problems/day16/\353\260\225\354\234\240\354\247\204.ts" @@ -0,0 +1,39 @@ + +// 실무에서는 상품 상세 페이지의 동적 라우트에서 params.id로 상품을 조회한 뒤, 그 응답값으로 generateMetadata에서 title, description, open graph, canonical 정보를 생성합니다. 페이지 렌더링과 메타데이터 생성이 같은 상품 조회 함수를 재사용하도록 분리하는 방식이 일반적입니다. + +// ## 문제 + +// 쇼핑몰 상품 페이지에서 상품의 이름과 설명을 기반으로 SEO 메타데이터를 동적으로 생성하는 함수를 작성하세요. 이 함수는 Next.js의 generateMetadata 기능을 활용하여 상품 페이지의 메타데이터를 설정합니다. + +// ## 코드 + +const product = { + id: 101, + name: 'Wireless Headphones', + description: 'High quality wireless headphones with noise cancellation', + price: 299.99 +}; + +type ProductType = { + id: number, + name: string, + description: string, + price: number +} + +// TODO: 여기에 구현하세요 +function generateProductMetadata(product: ProductType) { + return { + title: product.name, + description: product.description, + }; +} + + +// ## 요구사항 + +// 1. 상품의 이름을 메타데이터의 title로 설정해야 합니다. +// 2. 상품의 설명을 메타데이터의 description으로 설정해야 합니다. +// 3. 메타데이터는 객체 형태로 반환되어야 합니다. + + From fd1ed121816ff4d363c7d4d1b38e0e41a4a7a3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A7=80=EB=8B=88?= <117137463+yujinimda@users.noreply.github.com> Date: Thu, 2 Apr 2026 00:05:43 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Update=20problems/day16/=EB=B0=95=EC=9C=A0?= =?UTF-8?q?=EC=A7=84.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- "problems/day16/\353\260\225\354\234\240\354\247\204.ts" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/problems/day16/\353\260\225\354\234\240\354\247\204.ts" "b/problems/day16/\353\260\225\354\234\240\354\247\204.ts" index f158ee0..526d663 100644 --- "a/problems/day16/\353\260\225\354\234\240\354\247\204.ts" +++ "b/problems/day16/\353\260\225\354\234\240\354\247\204.ts" @@ -22,8 +22,8 @@ type ProductType = { } // TODO: 여기에 구현하세요 -function generateProductMetadata(product: ProductType) { - return { +function generateProductMetadata(product: ProductType): { title: string; description: string } { + return { title: product.name, description: product.description, }; From e0f3d2b59880ff4c944d3a22036a343280a46049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A7=80=EB=8B=88?= <117137463+yujinimda@users.noreply.github.com> Date: Thu, 2 Apr 2026 00:05:50 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Update=20problems/day16/=EB=B0=95=EC=9C=A0?= =?UTF-8?q?=EC=A7=84.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- .../day16/\353\260\225\354\234\240\354\247\204.ts" | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git "a/problems/day16/\353\260\225\354\234\240\354\247\204.ts" "b/problems/day16/\353\260\225\354\234\240\354\247\204.ts" index 526d663..73a8517 100644 --- "a/problems/day16/\353\260\225\354\234\240\354\247\204.ts" +++ "b/problems/day16/\353\260\225\354\234\240\354\247\204.ts" @@ -15,11 +15,11 @@ const product = { }; type ProductType = { - id: number, - name: string, - description: string, - price: number -} + id: number; + name: string; + description: string; + price: number; +}; // TODO: 여기에 구현하세요 function generateProductMetadata(product: ProductType): { title: string; description: string } {