-
Notifications
You must be signed in to change notification settings - Fork 271
/
socials.ts
36 lines (33 loc) · 864 Bytes
/
socials.ts
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
import { ComponentType, SVGProps } from 'react';
import {
Youtube,
Github,
Discord,
Twitter,
Reddit,
LinkedIn,
Instagram,
Facebook,
} from '../common/icons';
const map: Array<{
name: string;
Icon: ComponentType<SVGProps<SVGSVGElement>>;
}> = [
{ name: 'Youtube', Icon: Youtube },
{ name: 'GitHub', Icon: Github },
{ name: 'Discord', Icon: Discord },
{ name: 'Twitter', Icon: Twitter },
{ name: 'Reddit', Icon: Reddit },
{ name: 'LinkedIn', Icon: LinkedIn },
{ name: 'Instagram', Icon: Instagram },
{ name: 'Facebook', Icon: Facebook },
];
// Returns an object with icon and name for given url
export default function get_socials_data(url: string): (typeof map)[number] {
for (let i = 0; i < map.length; i++) {
if (url.toLowerCase().includes(map[i].name.toLowerCase())) {
return map[i];
}
}
return null;
}