1 import { Metadata } from "next"
2 import { getBaseSpecs } from "../../../lib"
3 import {
4 apiRefMetadataBase,
5 getIntroSection,
6 getTagBySlug,
7 isArea,
8 } from "@/utils/area"
9
10 export const dynamic = "force-dynamic"
11
12 type SectionPageProps = {
13 params: Promise<{ area: string; section: string }>
14 }
15
16 // The section content (intro section or tag) is rendered by the layout so that
17 // tag <-> operation navigation only swaps this page segment. This page exists
18 // for the route and its metadata.
19 const SectionPage = () => null
20
21 export default SectionPage
22
23 export async function generateMetadata({
24 params,
25 }: SectionPageProps): Promise<Metadata> {
26 const { area, section } = await params
27 if (!isArea(area)) {
28 return {}
29 }
30
31 const introSection = getIntroSection(area, section)
32 const data = await getBaseSpecs(area)
33 const tag = introSection ? undefined : getTagBySlug(data, section)
34 const title = introSection?.title || tag?.name
35
36 return {
37 title: title ? `${title} - Medusa ${area} API Reference` : undefined,
38 metadataBase: apiRefMetadataBase,
39 }
40 }