-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.ts
More file actions
25 lines (20 loc) · 833 Bytes
/
index.ts
File metadata and controls
25 lines (20 loc) · 833 Bytes
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
import { writeFileSync } from 'fs';
import { stringify } from 'querystring';
import { get } from 'simple-icons';
import * as data from './badges.json';
const url = 'https://img.shields.io/badge';
const [badges, refs]: [string[], string[]] = [[], []];
for (const badge of data) {
const icon = get(badge.name);
if (!icon) continue;
const badgeURL = `${url}/${icon.title.split(' ').join('_')}-${badge.backgroundColor ?? icon.hex}?`;
const query = stringify({
style: 'for-the-badge',
labelColor: badge.labelColor ?? icon.hex,
logoColor: badge.logoColor ?? icon.hex,
logo: icon.slug
});
refs.push(`[${icon.title}]: ${badgeURL + query}`);
badges.push(`[![${icon.title}]](${badge.link} "${icon.title}")`);
}
writeFileSync('README.md', `${['# Programming Badges', badges.join(' \n'), refs.join('\n')].join('\n\n')}\n`);