Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame contribute delete
505 Bytes
import { readFile } from "node:fs/promises"
import { resolve } from "node:path"
export const readExampleFile = async (
name: string,
scope: "examples" | "ui" = "examples",
ext = "tsx",
) => {
const filePath = resolve("../compositions/src", scope, `${name}.${ext}`)
let fileContent = await readFile(filePath, "utf-8")
fileContent = fileContent
.replaceAll("compositions/ui", "@/components/ui")
.replace(/export const \w+ = \(\) => \{/, "const Demo = () => {")
return fileContent
}