-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
64 lines (52 loc) · 1.43 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const simpleIcons = require("simple-icons");
const fs = require("fs");
const path = require("path");
const { hexToRGB, brightness, generate, groupNames } = require("./utils");
var data = [];
var dataStore = [];
var count = 0;
for (const title in simpleIcons) {
const icon = simpleIcons[title];
const rgb = hexToRGB(icon.hex);
const br = brightness(...rgb);
const titleNorm = icon.title;
let logo = titleNorm.split(" ").join("-");
if (titleNorm.split("&").length > 1 || titleNorm.split(".").length > 1)
logo = icon.slug;
const name = titleNorm.split("-").join("");
const src = encodeURI(
`https://img.shields.io/badge/${name}-${
icon.hex
}.svg?style=for-the-badge&logo=${logo}&logoColor=${
br <= 0.69 ? "white" : "black"
}`
);
const link = `\`${src}\``;
count += 1;
dataStore.push({
name: titleNorm,
hex: icon.hex,
src: src,
color: br <= 0.69 ? "white" : "black",
svg: icon.path,
});
const iconData = [
titleNorm,
`[![Alt][${count}]][${count}]`,
link,
`[${count}]: ${src}`,
];
data.push(iconData);
}
var obj = { icons: dataStore };
try {
fs.writeFileSync(
path.join(__dirname, "data", "icons.json"),
JSON.stringify(obj)
);
} catch (err) {
console.error(err);
}
const catData = groupNames(data);
generate(catData);
// console.log(data);