-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpage.tsx
More file actions
59 lines (54 loc) · 1.58 KB
/
Copy pathpage.tsx
File metadata and controls
59 lines (54 loc) · 1.58 KB
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
54
55
56
57
58
59
import {
DocsBody,
DocsDescription,
DocsPage,
DocsTitle,
} from "fumadocs-ui/layouts/notebook/page";
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { OpenAPIPage } from "@/components/api-page";
import { SocialFooter } from "@/components/social-footer";
import { siteOpenGraph } from "@/lib/shared";
import { apiSource, getApiPageImage } from "@/lib/source";
export default async function Page(
props: PageProps<"/api-reference/[[...slug]]">,
) {
const params = await props.params;
const page = apiSource.getPage(params.slug);
if (!page) notFound();
return (
<DocsPage toc={page.data.toc} footer={{ children: <SocialFooter /> }}>
<DocsTitle className="text-3xl tracking-tight sm:text-4xl">
{page.data.title}
</DocsTitle>
{page.data.description ? (
<DocsDescription className="mb-0">
{page.data.description}
</DocsDescription>
) : null}
<DocsBody>
<OpenAPIPage {...page.data.getOpenAPIPageProps()} />
</DocsBody>
</DocsPage>
);
}
export function generateStaticParams() {
return apiSource.generateParams();
}
export async function generateMetadata(
props: PageProps<"/api-reference/[[...slug]]">,
): Promise<Metadata> {
const params = await props.params;
const page = apiSource.getPage(params.slug);
if (!page) notFound();
return {
title: page.data.title,
description: page.data.description,
alternates: { canonical: page.url },
openGraph: {
...siteOpenGraph,
url: page.url,
images: getApiPageImage(page).url,
},
};
}