Switch to Node.JS stack

This commit is contained in:
Lucàs
2022-12-21 15:32:27 +01:00
parent 64ac979669
commit 6b87f411c6
17 changed files with 254 additions and 210 deletions
+38
View File
@@ -0,0 +1,38 @@
import {SimpleIcon} from 'simple-icons/types';
export default class Skill {
private title: string;
private slug: string;
private shield: string;
constructor(icon: SimpleIcon) {
this.title = icon.title;
this.slug = icon.slug;
this.shield = this.buildShield(icon);
}
private buildShield(icon: SimpleIcon): string {
const baseUrl = 'https://img.shields.io/static/v1';
const params = {
label: '',
message: icon.title,
color: icon.hex,
logo: icon.slug,
logoColor: 'white',
};
const shieldUrl = new URL(baseUrl);
Object.entries(params).forEach(param => {
const [key, value] = param;
shieldUrl.searchParams.append(key, value);
});
return shieldUrl.toString();
}
public static sortBySlug(a: Skill, b: Skill) {
if (a.slug < b.slug) return -1;
if (a.slug > b.slug) return 1;
return 0;
}
}