File size: 1,146 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import { notFound } from "next/navigation";
import { getPayloadClient } from "../../../payload/payloadClient";
import Blocks from "../../../components/Blocks";
import { Hero } from "../../../components/Hero";
import { AdminBar } from "../../../components/AdminBar";
import { Metadata } from "next";
export async function generateMetadata({
params: { slug },
}): Promise<Metadata> {
return {
title: slug,
};
}
const Page = async ({ params: { slug } }) => {
const payload = await getPayloadClient();
const pages = await payload.find({
collection: "pages",
where: {
slug: {
equals: slug || "home",
},
},
});
const page = pages.docs[0];
if (!page) return notFound();
return (
<>
<AdminBar adminBarProps={{ collection: "pages", id: page.id }} />
<Hero {...page.hero} />
<Blocks blocks={page.layout} />
</>
);
};
export async function generateStaticParams() {
const payload = await getPayloadClient();
const pages = await payload.find({
collection: "pages",
limit: 0,
});
return pages.docs.map(({ slug }) => ({ slug }));
}
export default Page;
|