2018-09-27 13:25:49 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { Icon } from 'antd';
|
2018-11-19 12:23:56 -08:00
|
|
|
import { SOCIAL_SERVICE, SocialInfo } from 'types';
|
2018-09-27 13:25:49 -07:00
|
|
|
|
|
|
|
const accountNameRegex = '([a-zA-Z0-9-_]*)';
|
2018-11-16 15:05:17 -08:00
|
|
|
export const SOCIAL_INFO: { [key in SOCIAL_SERVICE]: SocialInfo } = {
|
|
|
|
[SOCIAL_SERVICE.GITHUB]: {
|
|
|
|
service: SOCIAL_SERVICE.GITHUB,
|
2018-09-27 13:25:49 -07:00
|
|
|
name: 'Github',
|
|
|
|
format: `https://github.com/${accountNameRegex}`,
|
|
|
|
icon: <Icon type="github" />,
|
|
|
|
},
|
2018-11-16 15:05:17 -08:00
|
|
|
[SOCIAL_SERVICE.TWITTER]: {
|
|
|
|
service: SOCIAL_SERVICE.TWITTER,
|
2018-09-27 13:25:49 -07:00
|
|
|
name: 'Twitter',
|
|
|
|
format: `https://twitter.com/${accountNameRegex}`,
|
|
|
|
icon: <Icon type="twitter" />,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-11-19 12:23:56 -08:00
|
|
|
export function socialMediaToUrl(service: SOCIAL_SERVICE, username: string): string {
|
|
|
|
return SOCIAL_INFO[service].format.replace(accountNameRegex, username);
|
2018-09-27 13:25:49 -07:00
|
|
|
}
|