install simple-icons and add a few brand icons (recommendation from team at lucide)

This commit is contained in:
Jacob Overgaard
2024-04-05 16:19:00 +02:00
parent 9a5fe32c61
commit bcbbe4965c
17 changed files with 117 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ const umbracoSvgDirectory = `${moduleDirectory}/svgs`;
const iconMapJson = `${moduleDirectory}/icon-dictionary.json`;
const lucideSvgDirectory = 'node_modules/lucide-static/icons';
const simpleIconsSvgDirectory = 'node_modules/simple-icons/icons';
const run = async () => {
var icons = await collectDictionaryIcons();
@@ -50,8 +51,39 @@ const collectDictionaryIcons = async () => {
};
icons.push(icon);
} catch(e) {
console.log(`Could not load file: '${path}'`);
} catch (e) {
console.log(`[Lucide] Could not load file: '${path}'`);
}
}
});
// SimpleIcons:
fileJSON.simpleIcons.forEach((iconDef) => {
if (iconDef.file && iconDef.name) {
const path = simpleIconsSvgDirectory + "/" + iconDef.file;
try {
const rawData = readFileSync(path);
let svg = rawData.toString()
const iconFileName = iconDef.name;
// SimpleIcons need to use fill="currentColor"
const pattern = /fill=/g;
if (!pattern.test(svg)) {
svg = svg.replace(/<path/g, '<path fill="currentColor"');
}
const icon = {
name: iconDef.name,
legacy: iconDef.legacy,
fileName: iconFileName,
svg,
output: `${iconsOutputDirectory}/${iconFileName}.js`,
};
icons.push(icon);
} catch (e) {
console.log(`[SimpleIcons] Could not load file: '${path}'`);
}
}
});