File size: 953 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import {
cleanupContent,
findMatchingDocs,
minifyContent,
parseComponent,
} from "@/lib/llms-utils"
export const dynamic = "force-static"
interface Params {
component: string
}
export async function GET(_request: Request, ctx: { params: Promise<Params> }) {
let { component: componentParam } = await ctx.params
const { minify, component } = parseComponent(componentParam)
let content = !minify
? `<SYSTEM>Documentation for the ${component} component in Chakra UI v3.</SYSTEM>\n\n`
: ""
const componentDocs = findMatchingDocs(component)
for (const doc of componentDocs) {
let llm = doc.llm
if (!llm || llm?.length === 0) continue
if (minify) llm = minifyContent(llm)
llm = cleanupContent(llm)
content += `# ${doc.title}\n\n${llm}\n\n`
}
return new Response(content, {
headers: {
"Content-Type": "text/plain; charset=utf-8",
"Cache-Control": "public, max-age=3600",
},
})
}
|