-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8e8184
commit 78f7156
Showing
8 changed files
with
116 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
2 changes: 2 additions & 0 deletions
2
src/app/(post)/result/[postId]/_components/CommentInput/index.tsx
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,3 +1,5 @@ | ||
'use client'; | ||
|
||
import { ChangeEvent, useState } from 'react'; | ||
|
||
import { useParams } from 'next/navigation'; | ||
|
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,9 @@ | ||
export const META = { | ||
title: 'picky', | ||
siteName: 'picky', | ||
description: '까다로운 고민에 대한 해답을 pick!', | ||
url: 'https://picky-fe.vercel.app/', | ||
keyword: ['고민', 'picky', 'pick', '투표', '추천', '결정'], | ||
image: '/picky/thumbnail.png', | ||
icon: '/app-Icon/icon-512x512.png', | ||
}; |
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,42 @@ | ||
import { getVoteDetail } from '@/src/apis/vote'; | ||
import { getMetadata } from '@/src/utils/getMetadata'; | ||
|
||
const RESULT_MESSAGE = '투표 결과를 확인하세요.'; | ||
const VOTE_MESSAGE = 'picky에서 투표해보세요!'; | ||
|
||
export const getGenerateMetadata = | ||
() => | ||
async ({ params }: { params: { postId: string } }) => { | ||
try { | ||
const postId = params.postId; | ||
const response = await getVoteDetail(postId); | ||
if (!response || !response.body) { | ||
return; | ||
} | ||
const { | ||
voteTitle, | ||
hasVoted, | ||
voteOptions, | ||
terminated: isTerminated, | ||
} = response.body; | ||
|
||
const thumbnailImageUrl = | ||
voteOptions && | ||
voteOptions | ||
.map(({ voteOptionImageUrl }) => voteOptionImageUrl) | ||
.filter(url => url)[0]; | ||
|
||
const title = `${voteTitle}`; | ||
const description = | ||
hasVoted || isTerminated ? RESULT_MESSAGE : VOTE_MESSAGE; | ||
|
||
return getMetadata({ | ||
title, | ||
description, | ||
asPath: `/Result/${postId}`, | ||
image: thumbnailImageUrl, | ||
}); | ||
} catch (error) { | ||
return; | ||
} | ||
}; |
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,54 @@ | ||
import type { Metadata } from 'next'; | ||
|
||
import { META } from '@/src/constants/meta'; | ||
|
||
interface GetMetadataProps { | ||
title?: string; | ||
description?: string; | ||
asPath?: string; | ||
image?: string; | ||
icon?: string; | ||
} | ||
|
||
export const getMetadata = (metadataProps?: GetMetadataProps) => { | ||
const { title, description, asPath, image, icon } = metadataProps || {}; | ||
|
||
const TITLE = title ? `${title} | picky` : META.title; | ||
const DESCRIPTION = description || META.description; | ||
const PAGE_URL = asPath ? META.url + asPath : META.url; | ||
const IMAGE = image || META.image; | ||
const ICON = icon || META.icon; | ||
const metadata: Metadata = { | ||
metadataBase: new URL(META.url), | ||
alternates: { | ||
canonical: PAGE_URL, | ||
}, | ||
manifest: '/manifest.json', | ||
title: TITLE, | ||
description: DESCRIPTION, | ||
keywords: [...META.keyword], | ||
icons: { | ||
icon: ICON, | ||
}, | ||
openGraph: { | ||
title: TITLE, | ||
description: DESCRIPTION, | ||
siteName: TITLE, | ||
locale: 'ko_KR', | ||
type: 'website', | ||
url: PAGE_URL, | ||
images: { | ||
url: IMAGE, | ||
}, | ||
}, | ||
twitter: { | ||
title: TITLE, | ||
description: DESCRIPTION, | ||
images: { | ||
url: IMAGE, | ||
}, | ||
}, | ||
}; | ||
|
||
return metadata; | ||
}; |