|
| 1 | +import { PROGRAM_CATEGORIES_MAP } from "@/lib/network/program-categories"; |
| 2 | +import { MarketplaceExternalListPage } from "@/ui/program-marketplace/external/marketplace-external-list-page"; |
| 3 | +import { |
| 4 | + getMarketplaceCanonicalUrl, |
| 5 | + slugToCategory, |
| 6 | +} from "@/ui/program-marketplace/utils/urls"; |
| 7 | +import { constructMetadata } from "@dub/utils"; |
| 8 | +import { Metadata } from "next"; |
| 9 | +import { notFound } from "next/navigation"; |
| 10 | + |
| 11 | +// Rendered dynamically so the actual (filtered/sorted/paged) view is produced |
| 12 | +// server-side and hydrates in place — no fallback swap. |
| 13 | +export const dynamic = "force-dynamic"; |
| 14 | + |
| 15 | +export async function generateMetadata(props: { |
| 16 | + params: Promise<{ categorySlug: string }>; |
| 17 | +}): Promise<Metadata> { |
| 18 | + const { categorySlug } = await props.params; |
| 19 | + const category = slugToCategory(categorySlug); |
| 20 | + |
| 21 | + if (!category) { |
| 22 | + return constructMetadata({ title: "Programs" }); |
| 23 | + } |
| 24 | + |
| 25 | + const categoryMeta = PROGRAM_CATEGORIES_MAP[category]; |
| 26 | + const label = categoryMeta?.label ?? category.replaceAll("_", " "); |
| 27 | + |
| 28 | + return constructMetadata({ |
| 29 | + title: `${label} Programs`, |
| 30 | + description: |
| 31 | + categoryMeta?.listPageDescription ?? |
| 32 | + `Partner programs in ${label.toLowerCase()}.`, |
| 33 | + canonicalUrl: getMarketplaceCanonicalUrl(`/marketplace/c/${categorySlug}`), |
| 34 | + }); |
| 35 | +} |
| 36 | + |
| 37 | +export default async function MarketplaceCategoryPage(props: { |
| 38 | + params: Promise<{ categorySlug: string }>; |
| 39 | + searchParams: Promise<{ [key: string]: string | string[] | undefined }>; |
| 40 | +}) { |
| 41 | + const { categorySlug } = await props.params; |
| 42 | + const searchParams = await props.searchParams; |
| 43 | + |
| 44 | + const category = slugToCategory(categorySlug); |
| 45 | + |
| 46 | + if (!category) { |
| 47 | + notFound(); |
| 48 | + } |
| 49 | + |
| 50 | + return ( |
| 51 | + <MarketplaceExternalListPage |
| 52 | + slug={["c", categorySlug]} |
| 53 | + fixedCategory={category} |
| 54 | + searchParams={searchParams} |
| 55 | + /> |
| 56 | + ); |
| 57 | +} |
0 commit comments