Merge pull request #266 from csarnataro/add-mastodon-to-social-links

Added Mastodon social link
This commit is contained in:
Ariful Alam
2023-02-14 21:10:53 +06:00
committed by GitHub
6 changed files with 47 additions and 10 deletions

View File

@@ -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: '',
@@ -445,7 +446,7 @@ Your avatar and bio will be fetched from GitHub automatically.
### Social Links ### 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 ```js
// gitprofile.config.js // gitprofile.config.js
@@ -454,6 +455,7 @@ const config = {
social: { social: {
linkedin: 'ariful-alam', linkedin: 'ariful-alam',
twitter: 'arif_szn', twitter: 'arif_szn',
mastodon: '',
facebook: '', facebook: '',
instagram: '', instagram: '',
dribbble: '', dribbble: '',

View File

@@ -13,6 +13,7 @@ const config = {
social: { social: {
linkedin: 'ariful-alam', linkedin: 'ariful-alam',
twitter: 'arif_szn', twitter: 'arif_szn',
mastodon: '',
facebook: '', facebook: '',
instagram: '', instagram: '',
dribbble: '', dribbble: '',

View File

@@ -246,6 +246,7 @@ GitProfile.propTypes = {
social: PropTypes.shape({ social: PropTypes.shape({
linkedin: PropTypes.string, linkedin: PropTypes.string,
twitter: PropTypes.string, twitter: PropTypes.string,
mastodon: PropTypes.string,
facebook: PropTypes.string, facebook: PropTypes.string,
instagram: PropTypes.string, instagram: PropTypes.string,
dribbble: PropTypes.string, dribbble: PropTypes.string,

View File

@@ -15,11 +15,38 @@ import {
FaDev, FaDev,
FaFacebook, FaFacebook,
FaGlobe, FaGlobe,
FaMastodon,
FaStackOverflow, FaStackOverflow,
} from 'react-icons/fa'; } from 'react-icons/fa';
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
@@ -44,14 +71,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 = [];
@@ -111,6 +130,14 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://twitter.com/${social.twitter}`} link={`https://twitter.com/${social.twitter}`}
/> />
)} )}
{social?.mastodon && (
<ListItem
icon={<FaMastodon className="mr-2" />}
title="Mastodon:"
value={getMastodonValue(social.mastodon)}
link={getMastodonLink(social.mastodon)}
/>
)}
{social?.linkedin && ( {social?.linkedin && (
<ListItem <ListItem
icon={<GrLinkedinOption className="mr-2" />} icon={<GrLinkedinOption className="mr-2" />}

View File

@@ -147,6 +147,7 @@ export const sanitizeConfig = (config) => {
social: { social: {
linkedin: config?.social?.linkedin, linkedin: config?.social?.linkedin,
twitter: config?.social?.twitter, twitter: config?.social?.twitter,
mastodon: config?.social?.mastodon,
facebook: config?.social?.facebook, facebook: config?.social?.facebook,
instagram: config?.social?.instagram, instagram: config?.social?.instagram,
dribbble: config?.social?.dribbble, dribbble: config?.social?.dribbble,

5
types/index.d.ts vendored
View File

@@ -49,6 +49,11 @@ export interface Social {
*/ */
twitter?: string; twitter?: string;
/**
* Mastodon
*/
mastodon?: string;
/** /**
* Facebook * Facebook
*/ */