mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-10-30 18:22:59 +00:00
Major fixes: - Fixed wagmi/Web3 SSR errors by lazy-loading config in Web3Provider - Added SidebarProvider to sidebar-demo components - Added 'use client' to 14 demo files with hooks/state/event handlers - Temporarily disabled force-static on blocks page Build progress: 0 → 258/1035 pages (25%) before hitting /blocks error Remaining issue: - /blocks page has function-passing error during static generation Package versions confirmed: - React 19.2.0 ✅ - Next.js 16.0.0 ✅ - Tailwind CSS 4.1.14 ✅
36 lines
964 B
TypeScript
36 lines
964 B
TypeScript
import fs from "fs"
|
|
import { Index } from "@/__registry__"
|
|
|
|
import { type Style } from "@/registry/styles"
|
|
|
|
export function processMdxForLLMs(content: string, style: Style["name"]) {
|
|
const componentPreviewRegex =
|
|
/<ComponentPreview[\s\S]*?name="([^"]+)"[\s\S]*?\/>/g
|
|
|
|
return content.replace(componentPreviewRegex, (match, name) => {
|
|
try {
|
|
const component = Index[style]?.[name]
|
|
if (!component?.files) {
|
|
return match
|
|
}
|
|
|
|
const src = component.files[0]?.path
|
|
if (!src) {
|
|
return match
|
|
}
|
|
|
|
let source = fs.readFileSync(src, "utf8")
|
|
// Replace registry paths with components path for Hanzo
|
|
source = source.replaceAll(`@/registry/${style}/`, "@/components/")
|
|
source = source.replaceAll("export default", "export")
|
|
|
|
return `\`\`\`tsx
|
|
${source}
|
|
\`\`\``
|
|
} catch (error) {
|
|
console.error(`Error processing ComponentPreview ${name}:`, error)
|
|
return match
|
|
}
|
|
})
|
|
}
|