Skip to content

Commit

Permalink
Revert contentType page
Browse files Browse the repository at this point in the history
  • Loading branch information
ProchaLu committed Jan 8, 2025
1 parent 7d2e907 commit e7a9081
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions app/[contentType]/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
import { contentTypesMap } from '../../../utils/content-types';
import Content from './content';

export async function generateMetadata({
params,
}: {
params: Params;
}): Promise<Metadata> {
type Params = {
params: Promise<{ slug: string; contentType: IContentType }>;
};

export async function generateMetadata({ params }: Params): Promise<Metadata> {
const { title, previewImage, description } = await getContentData(
(await params).slug,
(await params).contentType,
Expand Down Expand Up @@ -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 <WorkPage work={content} />;

Expand All @@ -92,7 +87,7 @@ export default async function ContentPage({ params }: { params: Params }) {
{content.title}
</h1>
<time className="block text-accent-4 mb-8">{content.date}</time>
{content.previewImage && (
{!!content.previewImage && (
<Image
className="pb-8 block object-cover"
src={content.previewImage}
Expand Down Expand Up @@ -126,7 +121,7 @@ function WorkPage({ work }: { work: IContentData }) {
<ul>
<TechStack techStack={work.techStack ?? []} />
<MetadataListItem item="Date" value={work.date.toString()} />
{work.problem && (
{Boolean(work.problem) && (
<MetadataListItem item="Problem" value={work.problem ?? ''} />
)}
</ul>
Expand Down

0 comments on commit e7a9081

Please sign in to comment.