Update tags (#224)

* Add script to add more tags

* add tags

* update tags

* Fix tags
This commit is contained in:
Eric Fennis
2021-02-12 16:07:57 +01:00
committed by GitHub
parent 90e86767d8
commit c4dfe6b8cb
4 changed files with 1699 additions and 260 deletions

View File

@@ -24,6 +24,7 @@
"build:es": "babel build -d dist/esm",
"build:bundles": "rollup -c rollup.config.js",
"optimize": "npx babel-node ./scripts/optimizeSvgs.js --presets @babel/env",
"addtags": "npx babel-node ./scripts/addMissingKeysToTags.js --presets @babel/env",
"test": "jest"
},
"devDependencies": {

View File

@@ -0,0 +1,41 @@
import path from 'path';
import tags from '../tags.json';
import { readSvgDirectory, writeFile } from './helpers';
const ICONS_DIR = path.resolve(__dirname, '../icons');
console.log(`Read all tags`);
const svgFiles = readSvgDirectory(ICONS_DIR);
const iconNames = svgFiles.map(icon => icon.split('.')[0]);
const iconTags = iconNames
.map(iconName => ({
name: iconName,
tags: tags[iconName] || [],
}))
.sort((a, b) => {
const nameA = a.name;
const nameB = b.name;
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
// names must be equal
return 0;
});
const newTags = iconTags.reduce((acc, { name, tags }) => {
acc[name] = tags;
return acc;
}, {});
const tagsContent = JSON.stringify(newTags, null, 2);
writeFile(tagsContent, 'tags.json', path.resolve(__dirname, '..'));

View File

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
// eslint-disable-next-line import/no-extraneous-dependencies
import getArgumentOptions from 'minimist';
import renderIconsObject from './render/renderIconsObject';

1916
tags.json

File diff suppressed because it is too large Load Diff