Allow different formats of Mastodon link
This commit is contained in:
parent
f38bbafb2d
commit
1229633a77
@ -213,13 +213,14 @@ const config = {
|
|||||||
social: {
|
social: {
|
||||||
linkedin: '',
|
linkedin: '',
|
||||||
twitter: '',
|
twitter: '',
|
||||||
|
mastodon: '',
|
||||||
facebook: '',
|
facebook: '',
|
||||||
instagram: '',
|
instagram: '',
|
||||||
dribbble: '',
|
dribbble: '',
|
||||||
behance: '',
|
behance: '',
|
||||||
medium: '',
|
medium: '',
|
||||||
dev: '',
|
dev: '',
|
||||||
stackoverflow: '',
|
stackoverflow: '', // format: userid/username
|
||||||
website: '',
|
website: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
email: '',
|
email: '',
|
||||||
@ -451,7 +452,7 @@ module.exports = {
|
|||||||
social: {
|
social: {
|
||||||
linkedin: 'ariful-alam',
|
linkedin: 'ariful-alam',
|
||||||
twitter: 'arif_szn',
|
twitter: 'arif_szn',
|
||||||
mastodon: 'mastodon-server/@arifszn',
|
mastodon: '',
|
||||||
facebook: '',
|
facebook: '',
|
||||||
instagram: '',
|
instagram: '',
|
||||||
dribbble: '',
|
dribbble: '',
|
||||||
|
|||||||
@ -13,7 +13,7 @@ const config = {
|
|||||||
social: {
|
social: {
|
||||||
linkedin: 'ariful-alam',
|
linkedin: 'ariful-alam',
|
||||||
twitter: 'arif_szn',
|
twitter: 'arif_szn',
|
||||||
mastodon: 'mastodon.social/@arifszn', // format: mastodon-server/@username
|
mastodon: '',
|
||||||
facebook: '',
|
facebook: '',
|
||||||
instagram: '',
|
instagram: '',
|
||||||
dribbble: '',
|
dribbble: '',
|
||||||
|
|||||||
@ -21,6 +21,32 @@ import {
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { skeleton } from '../../helpers/utils';
|
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 }) => {
|
const ListItem = ({ icon, title, value, link, skeleton = false }) => {
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
@ -48,14 +74,6 @@ const ListItem = ({ icon, title, value, link, skeleton = false }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
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 Details = ({ profile, loading, social, github }) => {
|
||||||
const renderSkeleton = () => {
|
const renderSkeleton = () => {
|
||||||
let array = [];
|
let array = [];
|
||||||
@ -119,8 +137,8 @@ const Details = ({ profile, loading, social, github }) => {
|
|||||||
<ListItem
|
<ListItem
|
||||||
icon={<FaMastodon className="mr-2" />}
|
icon={<FaMastodon className="mr-2" />}
|
||||||
title="Mastodon:"
|
title="Mastodon:"
|
||||||
value={social.mastodon}
|
value={getMastodonValue(social.mastodon)}
|
||||||
link={`https://${social.mastodon}`}
|
link={getMastodonLink(social.mastodon)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{social?.linkedin && (
|
{social?.linkedin && (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user