Files
shadcn-ui/apps/v4/lib/llm.ts
shadcn 04432835f9 feat: new components (#8334)
* feat: add field.tsx and update blocks

* feat: add input group

* feat: implement button group

* fix

* fix

* wip

* fix: button group

* feat: update field

* fix

* feat

* feat: cooked

* fix

* chore: build registry

* feat: add kbd component

* chore: update input group demo

* feat: update kbd component

* feat: add empty

* feat: add spinner

* refactor: input group

* feat: blocks

* fix

* fix: app sidebar

* feat: add label to app sidebar

* fix

* fix

* fix

* fix

* fix

* feat

* feat

* fix

* docs: button group

* feat: add docs

* docs: kbd

* docs: empty

* fix

* docs

* docs

* feat: add sink link

* fix

* fix

* docs

* feat: add new page

* fix

* fix

* fix

* fix

* fix

* fix

* feat: add registration form

* fix: chat settings

* fix

* fix preview

* fix examples

* feat: add changelog

* fix

* fix

* fix

* fix

* fix

* feat(www): add t3 versions

* chore: build registry

* fix

* fix

* fix

* feat: inline code examples for llm

* fix

* feat: home

* fix

* fix

* fix

* fix

* fix

* chore: changelog

* fix

* fix

* fix

* fix: callout

* fix
2025-10-03 21:05:22 +04:00

34 lines
829 B
TypeScript

import fs from "fs"
import { Index } from "@/registry/__index__"
export function processMdxForLLMs(content: string) {
const componentPreviewRegex =
/<ComponentPreview\s+[^>]*name="([^"]+)"[^>]*\/>/g
return content.replace(componentPreviewRegex, (match, name) => {
try {
const component = Index[name]
if (!component?.files) {
return match
}
const src = component.files[0]?.path
if (!src) {
return match
}
let source = fs.readFileSync(src, "utf8")
source = source.replaceAll(`@/registry/new-york-v4/`, "@/components/")
source = source.replaceAll("export default", "export")
return `\`\`\`tsx
${source}
\`\`\``
} catch (error) {
console.error(`Error processing ComponentPreview ${name}:`, error)
return match
}
})
}