Files
shadcn-ui/apps/www/app/(blocks)/blocks/[style]/[name]/page.tsx
shadcn f47bb973be feat: e-commerce dashboard blocks (#3236)
* feat(blocks): add e-commerce dashboard

* feat(blocks): add products pages

* style(blocks): run prettier

* feat(www): update dashboard-05

* feat(www): update gap for dashboard-05

* feat(www): update dashboards

* fix(www): review a11y for new blocks

* fix(blocks): a11y for dashboard-07

* fix(www): blocks background

* chore: update registry
2024-03-29 00:14:32 +04:00

89 lines
1.7 KiB
TypeScript

import { Metadata } from "next"
import { notFound } from "next/navigation"
import { siteConfig } from "@/config/site"
import { getAllBlockIds, getBlock } from "@/lib/blocks"
import { absoluteUrl, cn } from "@/lib/utils"
import { Style, styles } from "@/registry/styles"
import "@/styles/mdx.css"
import "public/registry/themes.css"
export async function generateMetadata({
params,
}: {
params: {
style: Style["name"]
name: string
}
}): Promise<Metadata> {
const { name, style } = params
const block = await getBlock(name, style)
if (!block) {
return {}
}
return {
title: block.name,
description: block.description,
openGraph: {
title: block.name,
description: block.description,
type: "article",
url: absoluteUrl(`/blocks/${block.name}`),
images: [
{
url: siteConfig.ogImage,
width: 1200,
height: 630,
alt: siteConfig.name,
},
],
},
twitter: {
card: "summary_large_image",
title: block.name,
description: block.description,
images: [siteConfig.ogImage],
creator: "@shadcn",
},
}
}
export async function generateStaticParams() {
const blockIds = await getAllBlockIds()
return styles
.map((style) =>
blockIds.map((name) => ({
style: style.name,
name,
}))
)
.flat()
}
export default async function BlockPage({
params,
}: {
params: {
style: Style["name"]
name: string
}
}) {
const { name, style } = params
const block = await getBlock(name, style)
if (!block) {
return notFound()
}
const Component = block.component
return (
<div className={cn(block.container?.className || "", "theme-zinc")}>
<Component />
</div>
)
}