Skip to content

Commit

Permalink
feat: add dynamic work page
Browse files Browse the repository at this point in the history
  • Loading branch information
asbhogal committed Nov 29, 2024
1 parent 5c0cb3e commit b3ab5d5
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/app/(frontend)/work/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
export default async function Page() {
import { getPayload } from 'payload';
import configPromise from '@payload-config';
import { Metadata, ResolvingMetadata } from 'next';

interface Props {
params: Promise<{ slug: string }>
}

export async function generateMetadata({ params }: Props, _: ResolvingMetadata): Promise<Metadata> {
const { slug } = await params;

const payload = await getPayload({
config: configPromise,
});

const data = await payload.find({
collection: 'projects',
depth: 2,
where: {
slug: {
equals: slug,
},
},
});

return {
description: data.docs.find((doc) => doc.slug === slug)?.description?.toString() || '',
title: `${data.docs.find((doc) => doc.slug === slug)?.title} | Aman Singh Bhogal`,
};
}

export default async function Page({ params }: Props) {
const { slug } = await params;
return (
<div>
<h1>Page</h1>
<h1>{slug}</h1>
</div>
);
}

0 comments on commit b3ab5d5

Please sign in to comment.