Skip to content

Commit

Permalink
🔧 fix: Next.js 15 비동기 API 마이그레이션
Browse files Browse the repository at this point in the history
- params와 searchParams를 Promise 타입으로 변경
- generateMetadata와 Page 컴포넌트에서 await 사용
- 타입 에러 해결
  • Loading branch information
gr22nist committed Nov 15, 2024
1 parent ccb0a05 commit 2d3bef3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/projects/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { ProjectBackground } from '@/components/project/ProjectBackground'
import { ProjectHeader } from '@/components/project/ProjectHeader'
import { Metadata } from "next"

type Props = {
params: Promise<{ id: string }>
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
type Params = Promise<{ id: string }>
type SearchParams = Promise<{ [key: string]: string | string[] | undefined }>

interface Props {
params: Params
searchParams: SearchParams
}

export default async function ProjectPage(props: Props) {
const params = await props.params;
const params = await props.params
const project = projects.find(p => p.id === params.id)

if (!project) {
Expand All @@ -28,8 +31,9 @@ export default async function ProjectPage(props: Props) {
</div>
)
}

export async function generateMetadata(props: Props): Promise<Metadata> {
const params = await props.params;
const params = await props.params
const project = projects.find(p => p.id === params.id)

if (!project) {
Expand All @@ -40,6 +44,8 @@ export async function generateMetadata(props: Props): Promise<Metadata> {

return {
title: `${project.title} | DEVIN DOWN`,
description: project.description
description: Array.isArray(project.description)
? project.description.join(' ')
: project.description
}
}

0 comments on commit 2d3bef3

Please sign in to comment.