diff --git a/src/utils/parseReactSvgContent.ts b/src/utils/parseReactSvgContent.ts new file mode 100644 index 0000000..0d8c677 --- /dev/null +++ b/src/utils/parseReactSvgContent.ts @@ -0,0 +1,33 @@ +import { parse, print, type Module } from "@swc/core"; + +interface ParseReactSvgOptions { + componentName: string; + svgCode: string; + typescript: boolean; + minify?: boolean; +} + +export const parseReactSvgContent = async ({ + componentName, + svgCode, + typescript, + minify = false, +}: ParseReactSvgOptions) => { + let structuredCode = ""; + + if (typescript) { + structuredCode = + `import * as React from 'react';\n\n` + + `const ${componentName} = (props: React.SVGProps) => (\n ${svgCode.replace(" (\n ${svgCode.replace("