diff --git a/README.md b/README.md index ee8b786..7eacb4d 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: '', @@ -451,7 +452,7 @@ module.exports = { social: { linkedin: 'ariful-alam', twitter: 'arif_szn', - mastodon: 'mastodon-server/@arifszn', + mastodon: '', facebook: '', instagram: '', dribbble: '', diff --git a/gitprofile.config.js b/gitprofile.config.js index fec3902..c843ff8 100644 --- a/gitprofile.config.js +++ b/gitprofile.config.js @@ -13,7 +13,7 @@ const config = { social: { linkedin: 'ariful-alam', twitter: 'arif_szn', - mastodon: 'mastodon.social/@arifszn', // format: mastodon-server/@username + mastodon: '', facebook: '', instagram: '', dribbble: '', diff --git a/src/components/details/index.jsx b/src/components/details/index.jsx index 2fd0d59..97303bb 100644 --- a/src/components/details/index.jsx +++ b/src/components/details/index.jsx @@ -21,6 +21,32 @@ import { 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 = []; @@ -119,8 +137,8 @@ const Details = ({ profile, loading, social, github }) => { } title="Mastodon:" - value={social.mastodon} - link={`https://${social.mastodon}`} + value={getMastodonValue(social.mastodon)} + link={getMastodonLink(social.mastodon)} /> )} {social?.linkedin && (