Fix ts icon generation formatting

Improved icon generation to use manual formatting instead of JSON.stringify for better readability and consistency with other icon files.
This commit is contained in:
Dannon Baker
2025-10-30 21:41:54 -04:00
parent 3657fa3ba2
commit 81c24f3cd4
4 changed files with 26 additions and 18 deletions
+3 -3
View File
@@ -18,8 +18,8 @@ import { galaxyLogo } from "@/components/icons/galaxyIcons";
---
- **galaxyLogo**: `import { galaxyLogo } from '@/components/icons/galaxyIcons';`
- **textLarger**: `import { textLarger } from '@/components/icons/galaxyIcons';`
- **textSmaller**: `import { textSmaller } from '@/components/icons/galaxyIcons';`
- **galaxyLogo**: `import { galaxyLogo } from "@/components/icons/galaxyIcons";`
- **textLarger**: `import { textLarger } from "@/components/icons/galaxyIcons";`
- **textSmaller**: `import { textSmaller } from "@/components/icons/galaxyIcons";`
---
+3 -3
View File
@@ -101,16 +101,16 @@ function makeMarkdown(iconDefinitions) {
content += "## Usage\n\n";
content += "```vue\n";
content += "<script setup>\n";
content += "import { galaxyLogo } from '@/components/icons/galaxyIcons';\n";
content += 'import { galaxyLogo } from "@/components/icons/galaxyIcons";\n';
content += "</script>\n\n";
content += "<template>\n";
content += ' <FontAwesomeIcon :icon="galaxyLogo" />\n';
content += ' <FontAwesomeIcon :icon="galaxyLogo" />\n';
content += "</template>\n";
content += "```\n\n";
content += "---\n\n";
iconDefinitions.forEach((icon) => {
content += `- **${icon.iconName}**: \`import { ${icon.iconName} } from '@/components/icons/galaxyIcons';\`\n`;
content += `- **${icon.iconName}**: \`import { ${icon.iconName} } from "@/components/icons/galaxyIcons";\`\n`;
});
content += "\n---\n";
+19 -11
View File
@@ -23,7 +23,7 @@ function generateIconsTypeScript() {
// Galaxy custom icons
// Generated from: ${iconsJsonPath}
// To regenerate, run: npm run icons
// To regenerate: node icons/generate_ts_icons.js
// Matches FontAwesome's structure
export interface GalaxyIconDefinition {
@@ -41,21 +41,29 @@ export type IconLike = IconDefinition | GalaxyIconDefinition;
// Convert icon name to camelCase for JavaScript export
const exportName = icon.iconName;
content += `export const ${exportName}: GalaxyIconDefinition = ${JSON.stringify(
{
iconName: icon.iconName,
prefix: icon.prefix,
icon: icon.icon,
},
null,
4,
)};
// Format the icon data manually to match the expected style
const iconData = icon.icon;
const formattedIcon = `{
iconName: "${icon.iconName}",
prefix: "${icon.prefix}",
icon: [
${iconData[0]},
${iconData[1]},
[],
"",
[
${iconData[4].map((path) => `"${path}"`).join(",\n ")},
],
],
};`;
content += `export const ${exportName}: GalaxyIconDefinition = ${formattedIcon}
`;
});
// Write the TypeScript file
fs.writeFileSync(outputPath, content);
fs.writeFileSync(outputPath, content.trimEnd() + "\n");
console.log(`Generated Galaxy icons TypeScript exports at: ${outputPath}`);
console.log(`Exported ${icons.length} icons: ${icons.map((i) => i.iconName).join(", ")}`);
}
+1 -1
View File
@@ -2,7 +2,7 @@ import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
// Galaxy custom icons
// Generated from: /Users/dannon/work/galaxy/client/src/assets/icons.json
// To regenerate, run: npm run icons
// To regenerate: node icons/generate_ts_icons.js
// Matches FontAwesome's structure
export interface GalaxyIconDefinition {