1 import { Metadata } from "next"
2 import { apiRefPaths } from "@/utils/api-ref-paths"
3 import { apiRefMetadataBase, isArea } from "@/utils/area"
4
5 export const dynamic = "force-dynamic"
6
7 type OperationPageProps = {
8 params: Promise<{ area: string; section: string; operation: string }>
9 }
10
11 // The tag (with all its operations) is rendered by the [section] layout, which
12 // stays mounted across tag <-> operation navigation. Scrolling to the active
13 // operation is handled client-side (TagOperation reacts to the active path), so
14 // this page only exists for the route and its metadata.
15 const OperationPage = () => null
16
17 export default OperationPage
18
19 export async function generateMetadata({
20 params,
21 }: OperationPageProps): Promise<Metadata> {
22 const { area, section, operation } = await params
23 if (!isArea(area)) {
24 return {}
25 }
26
27 const tagEntry = apiRefPaths[area]?.tags?.[section]
28 const operationEntry = tagEntry
29 ? Object.values(tagEntry.operations).find((op) => op.slug === operation)
30 : undefined
31 const title = operationEntry?.title
32
33 return {
34 title: title ? `${title} - Medusa ${area} API Reference` : undefined,
35 metadataBase: apiRefMetadataBase,
36 }
37 }