Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame contribute delete
828 Bytes
import { ProjectSdk } from "@/utils/project-sdk"
import { isChartComponent } from "@/utils/shared"
interface Params {
id: string
}
export async function GET(_req: Request, ctx: { params: Promise<Params> }) {
const { id: exampleId } = await ctx.params
const project = new ProjectSdk()
const component = project.getComponentFromExample(exampleId)
if (!component) {
return new Response(JSON.stringify({ error: "Component not found" }), {
status: 404,
headers: {
"Content-Type": "application/json",
},
})
}
const example = project.parseExample(
component,
isChartComponent(component)
? `charts/${exampleId}.tsx`
: `${exampleId}.tsx`,
)
return new Response(JSON.stringify(example), {
headers: {
"Content-Type": "application/json",
},
})
}