1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2025-07-02 22:16:54 +02:00

Simplify how scripts get icon slugs (#5066)

* Accept icon rather than title in `iconToSlug`

This removes the need in (most of the) calls to this function to
seperately check if there is a custom slug already defined for the icon.

* Rename `titleToSlug` to `getIconSlug`

* Revert unnecessary style change

* Update function documentation

* Keep `titleToSlug` and add `getIconSlug` helper

Unfortunately `this` is not available because we're using arrow syntax
for these functions, but refering to `titleToSlug` through
`module.exports` works fine as well.

* Fix parameter name in `getIconSlug` docs
This commit is contained in:
Eric Cornelissen
2021-02-22 14:15:37 +01:00
committed by GitHub
parent 1df43dd50b
commit 8431fd9683
5 changed files with 14 additions and 8 deletions

View File

@ -4,6 +4,12 @@
*/
module.exports = {
/**
* Get the slug/filename for an icon.
* @param {Object} icon The icon data as it appears in _data/simple-icons.json
*/
getIconSlug: icon => icon.slug || module.exports.titleToSlug(icon.title),
/**
* Converts a brand title into a slug/filename.
* @param {String} title The title to convert