diff --git a/lib/load-simple-icons.js b/lib/load-simple-icons.js index a17b7ce8a2426c3530e08c6014e3f5cac4d38ea6..6f9590f261da87c9d2fe82add4a166f25a04e286 100644 --- a/lib/load-simple-icons.js +++ b/lib/load-simple-icons.js @@ -1,4 +1,4 @@ -import originalSimpleIcons from 'simple-icons' +import * as originalSimpleIcons from 'simple-icons/icons' import { svg2base64 } from './svg-helpers.js' function loadSimpleIcons() { @@ -14,10 +14,10 @@ function loadSimpleIcons() { // https://github.com/badges/shields/issues/4273 Object.keys(originalSimpleIcons).forEach(key => { const icon = originalSimpleIcons[key] - const title = icon.title.toLowerCase() - const legacyTitle = title.replace(/ /g, '-') + const { title, slug, hex } = icon + icon.base64 = { - default: svg2base64(icon.svg.replace('<svg', `<svg fill="#${icon.hex}"`)), + default: svg2base64(icon.svg.replace('<svg', `<svg fill="#${hex}"`)), light: svg2base64(icon.svg.replace('<svg', `<svg fill="whitesmoke"`)), dark: svg2base64(icon.svg.replace('<svg', `<svg fill="#333"`)), } @@ -26,14 +26,17 @@ function loadSimpleIcons() { // (e.g. 'Hive'). If a by-title reference we generate for // backwards compatibility collides with a proper slug from Simple Icons // then do nothing, so that the proper slug will always map to the correct icon. - if (!(title in originalSimpleIcons)) { - simpleIcons[title] = icon + // Starting in v7, the exported object with the full icon set has updated the keys + // to include a lowercase `si` prefix, and utilizes proper case naming conventions. + if (!(`si${title}` in originalSimpleIcons)) { + simpleIcons[title.toLowerCase()] = icon } - if (!(legacyTitle in originalSimpleIcons)) { - simpleIcons[legacyTitle] = icon + const legacyTitle = title.replace(/ /g, '-') + if (!(`si${legacyTitle}` in originalSimpleIcons)) { + simpleIcons[legacyTitle.toLowerCase()] = icon } - simpleIcons[key] = icon + simpleIcons[slug] = icon }) return simpleIcons } diff --git a/package-lock.json b/package-lock.json index e539ba4ed0878ef2024af4e004b843967fc6407e..0ab947c04ab7097a51ecfab4ac0324861828b6cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,7 +49,7 @@ "qs": "^6.10.5", "query-string": "^7.1.1", "semver": "~7.3.7", - "simple-icons": "6.23.0", + "simple-icons": "7.0.0", "webextension-store-meta": "^1.0.5", "xmldom": "~0.6.0", "xpath": "~0.0.32" @@ -25916,9 +25916,9 @@ } }, "node_modules/simple-icons": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/simple-icons/-/simple-icons-6.23.0.tgz", - "integrity": "sha512-9ql+6OdW5Dnfx1/z5z8MYO2y+OM4Oj4XBvQY5Nlye4eW+Nf5igHzHIKKtTmFkvCmR0lrddZpe1F/89chgoUXhg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/simple-icons/-/simple-icons-7.0.0.tgz", + "integrity": "sha512-5jwnZ04C2PmdKrLe6HSZLmsmP77WvZtNau0hGgSqEi2pplcP3yiiE4/f0Emgix8tItWKsYkS1TQI75yZhr8Xjw==", "engines": { "node": ">=0.12.18" }, @@ -50405,9 +50405,9 @@ "dev": true }, "simple-icons": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/simple-icons/-/simple-icons-6.23.0.tgz", - "integrity": "sha512-9ql+6OdW5Dnfx1/z5z8MYO2y+OM4Oj4XBvQY5Nlye4eW+Nf5igHzHIKKtTmFkvCmR0lrddZpe1F/89chgoUXhg==" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/simple-icons/-/simple-icons-7.0.0.tgz", + "integrity": "sha512-5jwnZ04C2PmdKrLe6HSZLmsmP77WvZtNau0hGgSqEi2pplcP3yiiE4/f0Emgix8tItWKsYkS1TQI75yZhr8Xjw==" }, "simple-swizzle": { "version": "0.2.2", diff --git a/package.json b/package.json index c5800b7e5d37234981f7a862d4ed88be6c6d2055..6ce19364c65528810aa9d4b24cd9f6702c6b270c 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "qs": "^6.10.5", "query-string": "^7.1.1", "semver": "~7.3.7", - "simple-icons": "6.23.0", + "simple-icons": "7.0.0", "webextension-store-meta": "^1.0.5", "xmldom": "~0.6.0", "xpath": "~0.0.32"