diff --git a/.changeset/long-eggs-cough.md b/.changeset/long-eggs-cough.md new file mode 100644 index 0000000..b98ebc1 --- /dev/null +++ b/.changeset/long-eggs-cough.md @@ -0,0 +1,6 @@ +--- +"@icona/generator": patch +"@icona/types": patch +--- + +Add attributes in vue generators diff --git a/packages/generator/src/core/vue2.ts b/packages/generator/src/core/vue2.ts index 78f3d47..873c743 100644 --- a/packages/generator/src/core/vue2.ts +++ b/packages/generator/src/core/vue2.ts @@ -68,7 +68,7 @@ const createShimFile = async (targetPath: string) => { export const generateVue2 = async (props: Props) => { const { config, icons = getIconaIconsFile() } = props; const targetPath = getTargetPath(config.path || "vue2"); - const { genShimFile, genIndexFile } = config; + const { genShimFile, genIndexFile, attributes } = config; const componentNames = []; if (!icons) { @@ -100,8 +100,13 @@ export const generateVue2 = async (props: Props) => { const svgPath = resolve(targetPath, `${componentName}.vue`); componentNames.push(componentName); + const attributesString = Object.entries(attributes || {}) + .map(([key, value]) => `${key}="${value}"`) + .join(" "); + // SVG 파일 내용을 Vue 컴포넌트로 변환 const convertedSvg = svg + .replace(/ { export const generateVue3 = async (props: Props) => { const { config, icons = getIconaIconsFile() } = props; const targetPath = getTargetPath(config.path || "vue3"); - const { genShimFile, genIndexFile } = config; + const { genShimFile, genIndexFile, attributes } = config; const componentNames = []; if (!icons) { throw new Error("There is no icons data"); @@ -103,8 +103,13 @@ export const generateVue3 = async (props: Props) => { const svgPath = resolve(targetPath, `${componentName}.vue`); componentNames.push(componentName); + const attributesString = Object.entries(attributes || {}) + .map(([key, value]) => `${key}="${value}"`) + .join(" "); + // SVG 파일 내용을 Vue 컴포넌트로 변환 const convertedSvg = svg + .replace(/; } export interface Vue3Config extends BaseConfig { genShimFile?: boolean; genIndexFile?: boolean; + + attributes?: Record; } export interface IconaConfig {