-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathget-icon-data.js
More file actions
49 lines (40 loc) · 1.37 KB
/
get-icon-data.js
File metadata and controls
49 lines (40 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
/**
* Helper script to get icon data from Iconify API
* Usage: node scripts/get-icon-data.js <icon-name>
* Example: node scripts/get-icon-data.js material-symbols:search
*/
const iconName = process.argv[2];
if (!iconName) {
console.error('Usage: node scripts/get-icon-data.js <icon-name>');
console.error('Example: node scripts/get-icon-data.js material-symbols:search');
process.exit(1);
}
const [prefix, name] = iconName.split(':');
if (!prefix || !name) {
console.error('Icon name must be in format: <prefix>:<name>');
console.error('Example: material-symbols:search');
process.exit(1);
}
const url = `https://api.iconify.design/${prefix}.json?icons=${name}`;
fetch(url)
.then(res => res.json())
.then(data => {
const icon = data.icons[name];
if (!icon) {
console.error(`Icon "${name}" not found in set "${prefix}"`);
process.exit(1);
}
const width = icon.width || data.width || 24;
const height = icon.height || data.height || 24;
console.log('\n// Add this to src/utils/preload-icons.ts:\n');
console.log(`addIcon('${iconName}', {`);
console.log(`\tbody: '${icon.body}',`);
console.log(`\twidth: ${width},`);
console.log(`\theight: ${height},`);
console.log(`});\n`);
})
.catch(error => {
console.error('Error fetching icon data:', error.message);
process.exit(1);
});