simple-icons/scripts/templates/index.js
Eric Cornelissen c6a9346985 Generic get icon function for easier access to brands with "difficult" names (#1522)
* Add URL friendy/slug/file name as property to package icon objects

* Test new property

* Build index from template

* Add .get function to index.js export

* Test new .get function in index.js export

* Use Uglify-JS to minify the code in the package's index.js

* Update API in README.md

* Renaem test using "slug" instead of "name"
2019-07-14 21:05:38 +02:00

18 lines
443 B
JavaScript

var icons = {%s};
module.exports = icons;
module.exports.get = function(targetName) {
if (icons[targetName]) {
return icons[targetName];
} else {
var normalizedName = targetName.toLowerCase();
for (var iconName in icons) {
var icon = icons[iconName];
if ((icon.title && icon.title.toLowerCase() === normalizedName)
|| (icon.slug && icon.slug === normalizedName)) {
return icon;
}
}
}
}