mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-11-03 03:18:52 +00:00
Squash merge of shadcn-ui/ui main branch into hanzo/ui, bringing in: - [email protected] through [email protected] releases - New apps/v4 directory structure - Registry system improvements and MCP server - Framework support (Vue, Svelte, React Native) - New templates (vite-app, monorepo-next, laravel) - Zod 4 compatibility (scoped override for zod@>4) - Test fixture corrections for alias resolution All 867 merge conflicts resolved preserving Hanzo customizations. 1020/1020 shadcn tests pass.
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { notFound } from "next/navigation"
|
|
import { NextResponse, type NextRequest } from "next/server"
|
|
|
|
import { processMdxForLLMs } from "@/lib/llm"
|
|
import { source } from "@/lib/source"
|
|
import { getActiveStyle, type Style } from "@/registry/_legacy-styles"
|
|
|
|
export const revalidate = false
|
|
|
|
function getStyleFromSlug(slug: string[] | undefined, fallbackStyle: string) {
|
|
// Detect base from URL: /docs/components/base/... or /docs/components/radix/...
|
|
if (slug && slug[0] === "components" && slug[1]) {
|
|
if (slug[1] === "base") {
|
|
return "base-nova"
|
|
}
|
|
if (slug[1] === "radix") {
|
|
return "new-york-v4"
|
|
}
|
|
}
|
|
return fallbackStyle
|
|
}
|
|
|
|
export async function GET(
|
|
_req: NextRequest,
|
|
{ params }: { params: Promise<{ slug?: string[] }> }
|
|
) {
|
|
const [{ slug }, activeStyle] = await Promise.all([params, getActiveStyle()])
|
|
|
|
const page = source.getPage(slug)
|
|
|
|
if (!page) {
|
|
notFound()
|
|
}
|
|
|
|
const effectiveStyle = getStyleFromSlug(slug, activeStyle.name)
|
|
|
|
const processedContent = processMdxForLLMs(
|
|
await page.data.getText("raw"),
|
|
effectiveStyle as Style["name"]
|
|
)
|
|
|
|
return new NextResponse(processedContent, {
|
|
headers: {
|
|
"Content-Type": "text/markdown; charset=utf-8",
|
|
},
|
|
})
|
|
}
|
|
|
|
export function generateStaticParams() {
|
|
return source.generateParams()
|
|
}
|