diff --git a/README.md b/README.md index 84fa513..b6b7a34 100644 --- a/README.md +++ b/README.md @@ -213,13 +213,14 @@ const config = { social: { linkedin: '', twitter: '', + mastodon: '', facebook: '', instagram: '', dribbble: '', behance: '', medium: '', dev: '', - stackoverflow: '', + stackoverflow: '', // format: userid/username website: '', phone: '', email: '', @@ -445,7 +446,7 @@ Your avatar and bio will be fetched from GitHub automatically. ### Social Links -You can link your social media services you're using, including LinkedIn, Twitter, Facebook, Instagram, Dribbble, Behance, Medium, dev, Stack Overflow, personal website, phone and email. +You can link your social media services you're using, including LinkedIn, Twitter, Mastodon, Facebook, Instagram, Dribbble, Behance, Medium, dev, Stack Overflow, personal website, phone and email. ```js // gitprofile.config.js @@ -454,6 +455,7 @@ const config = { social: { linkedin: 'ariful-alam', twitter: 'arif_szn', + mastodon: '', facebook: '', instagram: '', dribbble: '', diff --git a/gitprofile.config.js b/gitprofile.config.js index 32e626f..6f0513d 100644 --- a/gitprofile.config.js +++ b/gitprofile.config.js @@ -13,6 +13,7 @@ const config = { social: { linkedin: 'ariful-alam', twitter: 'arif_szn', + mastodon: '', facebook: '', instagram: '', dribbble: '', diff --git a/src/components/GitProfile.jsx b/src/components/GitProfile.jsx index a63054e..8b7bdaa 100644 --- a/src/components/GitProfile.jsx +++ b/src/components/GitProfile.jsx @@ -246,6 +246,7 @@ GitProfile.propTypes = { social: PropTypes.shape({ linkedin: PropTypes.string, twitter: PropTypes.string, + mastodon: PropTypes.string, facebook: PropTypes.string, instagram: PropTypes.string, dribbble: PropTypes.string, diff --git a/src/components/details/index.jsx b/src/components/details/index.jsx index 61160aa..be92d23 100644 --- a/src/components/details/index.jsx +++ b/src/components/details/index.jsx @@ -15,11 +15,38 @@ import { FaDev, FaFacebook, FaGlobe, + FaMastodon, FaStackOverflow, } from 'react-icons/fa'; import PropTypes from 'prop-types'; import { skeleton } from '../../helpers/utils'; +const isCompanyMention = (company) => { + return company.startsWith('@') && !company.includes(' '); +}; + +const companyLink = (company) => { + return `https://github.com/${company.substring(1)}`; +}; + +const getMastodonValue = (mastodonURL) => { + const regex = /(https?:\/\/)?(www\.)?([^\s/]+)\/@(\w+)/; + + const match = mastodonURL.match(regex); + + if (match) { + const domain = match[3]; + const username = match[4]; + return `${domain}/@${username}`; + } + + return mastodonURL; +}; + +const getMastodonLink = (mastodonURL) => { + return mastodonURL.replace(/^(https?:\/\/)?(www\.)?/, 'https://'); +}; + const ListItem = ({ icon, title, value, link, skeleton = false }) => { return ( { ); }; -const isCompanyMention = (company) => { - return company.startsWith('@') && !company.includes(' '); -}; - -const companyLink = (company) => { - return `https://github.com/${company.substring(1)}`; -}; - const Details = ({ profile, loading, social, github }) => { const renderSkeleton = () => { let array = []; @@ -111,6 +130,14 @@ const Details = ({ profile, loading, social, github }) => { link={`https://twitter.com/${social.twitter}`} /> )} + {social?.mastodon && ( + } + title="Mastodon:" + value={getMastodonValue(social.mastodon)} + link={getMastodonLink(social.mastodon)} + /> + )} {social?.linkedin && ( } diff --git a/src/helpers/utils.jsx b/src/helpers/utils.jsx index ae508c6..ea73746 100644 --- a/src/helpers/utils.jsx +++ b/src/helpers/utils.jsx @@ -147,6 +147,7 @@ export const sanitizeConfig = (config) => { social: { linkedin: config?.social?.linkedin, twitter: config?.social?.twitter, + mastodon: config?.social?.mastodon, facebook: config?.social?.facebook, instagram: config?.social?.instagram, dribbble: config?.social?.dribbble, diff --git a/types/index.d.ts b/types/index.d.ts index 90b3b47..4692db7 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -49,6 +49,11 @@ export interface Social { */ twitter?: string; + /** + * Mastodon + */ + mastodon?: string; + /** * Facebook */