22 lines
603 B
TypeScript
22 lines
603 B
TypeScript
const socialIconMap = {
|
|
"facebook.com": "i-cib-facebook-f",
|
|
"twitter.com": "i-cib-twitter",
|
|
"x.com": "i-cib-twitter",
|
|
"instagram.com": "i-cib-instagram",
|
|
"youtube.com": "i-cib-youtube",
|
|
"linkedin.com": "i-cib-linkedin",
|
|
"tiktok.com": "i-cib-tiktok",
|
|
};
|
|
|
|
export function mapSocialIcon(url: string) {
|
|
try {
|
|
const domain = new URL(url).hostname.toLowerCase().replace(/^www\./, "");
|
|
const icon = socialIconMap[domain as keyof typeof socialIconMap];
|
|
if (!icon) throw new Error(`Média social introuvable ${url}`);
|
|
return icon;
|
|
}
|
|
catch {
|
|
return "i-lucide-globe";
|
|
}
|
|
}
|