mirror of
https://github.com/LucasVbr/LucasVbr.git
synced 2026-12-05 19:00:50 +00:00
Switch to Node.JS stack
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user