From 3a753611cedb7aadaafdd7a0e150e9f7a91bc1dc Mon Sep 17 00:00:00 2001 From: birjolaxew Date: Sun, 17 Sep 2017 03:48:02 +0200 Subject: [PATCH] Update index.js to use proper title->filename conversion --- index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 5d3fbb9c..95ca27f3 100644 --- a/index.js +++ b/index.js @@ -2,12 +2,14 @@ const dataFile = './_data/simple-icons.json'; const data = require(dataFile); const fs = require('fs'); -let Icons = {}; +const icons = {}; data.icons.forEach(i => { - i.name = i.title.toLowerCase().replace(/[^a-z0-9]/gim, ''); - i.svg = fs.readFileSync(`./icons/${i.name}.svg`, 'utf8'); - Icons[i.name] = i + const filename = i.title.toLowerCase() + .replace(/\+/g, "plus") + .replace(/[ .\-!’]/g, ''); + i.svg = fs.readFileSync(`./icons/${filename}.svg`, 'utf8'); + icons[i.title] = i }); -module.exports = Icons; +module.exports = icons;