@@ -6,36 +6,38 @@ export interface SocialLink {
66}
77
88export function getSocialLinks ( { key, url } : { key : string , url : string } ) {
9- const _key = key . toLowerCase ( )
9+ // Remove trailing "url" and convert to lowercase for better matching
10+ // For example, "twitterUrl" becomes "twitter", "linkedin_url" becomes "linkedin"
11+ const formattedKey = key . toLowerCase ( ) . replace ( / _ ? u r l $ / , '' )
1012
11- if ( _key . startsWith ( 'mastodon' ) ) {
13+ if ( formattedKey . startsWith ( 'mastodon' ) ) {
1214 return { url : url , name : 'Mastodon' , icon : 'social-mastodon' }
1315 }
14- if ( _key . startsWith ( 'pinterest' ) ) {
16+ if ( formattedKey . startsWith ( 'pinterest' ) ) {
1517 return { url : url , name : 'Pinterest' , icon : 'social-pinterest' }
1618 }
17- if ( _key . startsWith ( 'snapchat' ) ) {
19+ if ( formattedKey . startsWith ( 'snapchat' ) ) {
1820 return { url : url , name : 'Snapchat' , icon : 'social-snapchat' }
1921 }
20- if ( _key . startsWith ( 'instagram' ) ) {
22+ if ( formattedKey . startsWith ( 'instagram' ) ) {
2123 return { url : url , name : 'Instagram' , icon : 'social-instagram' }
2224 }
23- if ( _key . startsWith ( 'youtube' ) ) {
25+ if ( formattedKey . startsWith ( 'youtube' ) ) {
2426 return { url : url , name : 'Youtube' , icon : 'social-youtube' }
2527 }
26- if ( _key . startsWith ( 'linkedin' ) ) {
28+ if ( formattedKey . startsWith ( 'linkedin' ) ) {
2729 return { url : url , name : 'LinkedIn' , icon : 'social-linkedin' }
2830 }
29- if ( _key . startsWith ( 'facebook' ) ) {
31+ if ( formattedKey . startsWith ( 'facebook' ) ) {
3032 return { url : url , name : 'Facebook' , icon : 'social-facebook' }
3133 }
32- if ( _key . startsWith ( 'tiktok' ) ) {
34+ if ( formattedKey . startsWith ( 'tiktok' ) ) {
3335 return { url : url , name : 'Tiktok' , icon : 'social-tiktok' }
3436 }
35- if ( _key . startsWith ( 'spotify' ) ) {
37+ if ( formattedKey . startsWith ( 'spotify' ) ) {
3638 return { url : url , name : 'Spotify' , icon : 'social-spotify' }
3739 }
38- if ( _key . startsWith ( 'twitter' ) || _key . startsWith ( 'x_' ) ) {
40+ if ( formattedKey . startsWith ( 'twitter' ) || formattedKey === 'x' ) {
3941 return { url : url , name : 'X' , icon : 'social-x' }
4042 }
4143
0 commit comments