diff --git a/app/[contentType]/[slug]/page.tsx b/app/[contentType]/[slug]/page.tsx index 45e5e4b..533428d 100644 --- a/app/[contentType]/[slug]/page.tsx +++ b/app/[contentType]/[slug]/page.tsx @@ -14,11 +14,11 @@ import { import { contentTypesMap } from '../../../utils/content-types'; import Content from './content'; -export async function generateMetadata({ - params, -}: { - params: Params; -}): Promise { +type Params = { + params: Promise<{ slug: string; contentType: IContentType }>; +}; + +export async function generateMetadata({ params }: Params): Promise { const { title, previewImage, description } = await getContentData( (await params).slug, (await params).contentType, @@ -67,20 +67,15 @@ async function fetchContentData(slug: string, contentType: IContentType) { return await getContentData(slug, contentType); } -type Params = { - slug: string; - contentType: IContentType; -}; - -export default async function ContentPage({ params }: { params: Params }) { - const { slug, contentType } = params; +export default async function ContentPage({ params }: Params) { + const { slug, contentType } = await params; if (!contentTypesMap.has(contentType)) { return notFound(); } const content = await fetchContentData(slug, contentType); - if (content.draft) return notFound(); + if (content.draft) notFound(); if (contentType === 'works') return ; @@ -92,7 +87,7 @@ export default async function ContentPage({ params }: { params: Params }) { {content.title} - {content.previewImage && ( + {!!content.previewImage && ( - {work.problem && ( + {Boolean(work.problem) && ( )}