Files
wr.do/app/(marketing)/[slug]/page.tsx
2025-10-20 11:34:05 +08:00

64 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { notFound } from "next/navigation";
import { allPages } from "contentlayer/generated";
import { Mdx } from "@/components/content/mdx-components";
import "@/styles/mdx.scss";
import { Metadata } from "next";
import { constructMetadata } from "@/lib/utils";
export async function generateStaticParams() {
return allPages.map((page) => ({
slug: page.slugAsParams,
}));
}
export async function generateMetadata({
params,
}: {
params: { slug: string };
}): Promise<Metadata | undefined> {
const page = allPages.find((page) => page.slugAsParams === params.slug);
if (!page) {
return;
}
const { title, description } = page;
return constructMetadata({
title: `${title}  WR.DO`,
description: description,
});
}
export default async function PagePage({
params,
}: {
params: {
slug: string;
};
}) {
const page = allPages.find((page) => page.slugAsParams === params.slug);
if (!page) {
notFound();
}
return (
<article className="container max-w-3xl py-6 lg:py-12">
<div className="space-y-4">
<h1 className="inline-block font-heading text-4xl lg:text-5xl">
{page.title}
</h1>
{page.description && (
<p className="text-xl text-muted-foreground">{page.description}</p>
)}
</div>
<hr className="my-4" />
<Mdx code={page.body.code} />
</article>
);
}