feat: mapSocialIcon

This commit is contained in:
2026-01-30 11:18:10 -05:00
parent 980c5271ac
commit 6dd13ead91
3 changed files with 40 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
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";
}
}