forked from EddieHubCommunity/BioDrop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIcon.js
36 lines (31 loc) · 749 Bytes
/
Icon.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
import dynamic from "next/dynamic";
function defaultIcon() {
return dynamic(() => import("react-icons/fa").then((mod) => mod.FaGlobe));
}
export default function getIcon(name = "FaGlobe") {
let icon;
switch (name.slice(0, 2)) {
case "Fa":
icon = dynamic(() =>
import("react-icons/fa").then((mod) => {
let node = mod[name];
if (!node) node = defaultIcon();
return node;
})
);
break;
case "Si":
icon = dynamic(() =>
import("react-icons/si").then((mod) => {
let node = mod[name];
if (!node) node = defaultIcon();
return node;
})
);
break;
}
if (!icon) {
return defaultIcon();
}
return icon;
}