feat: add bluesky social link

This commit is contained in:
Kendall Morgan 2024-10-31 14:33:09 -07:00
parent 20f136b4ca
commit 5d6f83ff6b
No known key found for this signature in database
GPG key ID: CE253EFC7D3C5F93
3 changed files with 28 additions and 3 deletions

View file

@ -62,6 +62,7 @@ module.exports.Schema = Joi.object({
.required(),
twitter: Joi.string().pattern(new RegExp(/^@?(\w){1,15}$/)),
mastodon: Joi.string().pattern(new RegExp(/^@(\w){1,30}@(\w)+\.(.?\w)+$/)),
bluesky: Joi.string().pattern(new RegExp(/^@[\w-]+\.(?:[\w-]+\.)?[\w-]+$/)),
emoji: Joi.string().allow(''),
computer: Joi.string().valid('apple', 'windows', 'linux', 'bsd'),
phone: Joi.string().valid('iphone', 'android', 'windowsphone', 'flipphone'),

View file

@ -7,7 +7,7 @@ import * as icons from '../util/icons';
export default function Person({ person }) {
const url = new URL(person.url);
const twitter = person.twitter
? `https://unavatar.io/${person.twitter.replace('@', '')}`
? `https://unavatar.io/x/${person.twitter.replace('@', '')}`
: null;
const website = `https://unavatar.io/${url.host}`;
const unavatar = person.twitter
@ -93,8 +93,22 @@ export default function Person({ person }) {
</div>
)}
{/* If they have a bluesky, and no twitter/mastodon, show that */}
{person.bluesky && !person.twitter && (
<div className="SocialHandle">
<a
href={`https://bsky.app/profile/${person.bluesky.replace("@", "")}`}
target="_blank"
rel="noopener noreferrer"
>
<span className="at">@</span>
{person.bluesky.substring(1)}
</a>
</div>
)}
{/* If they have a mastodon, and no twitter, show that */}
{person.mastodon && !person.twitter && (
{person.mastodon && !person.twitter && !person.bluesky && (
<div className="SocialHandle">
<a
href={`https://${mastodonServer}/@${mastodonHandle}`}
@ -106,6 +120,7 @@ export default function Person({ person }) {
</a>
</div>
)}
</div>
</div>
);
@ -138,5 +153,13 @@ Person.propTypes = {
);
}
},
bluesky(props, propName, componentName) {
if (!/^@(\w)+\.(\w)+\.(\w)+$/.test(props[propName])) {
return new Error(
`Invalid prop \`${propName}\` supplied to` +
` \`${componentName}\`. This isn't a legit Bluesky handle.`
);
}
},
}),
};

View file

@ -8,6 +8,7 @@
* @property {string} country - flag emoji for contributor's country
* @property {string} [twitter] - optional Twitter username (beginning with `@`)
* @property {string} [mastodon] - optional Mastodon username & server (beginning with `@`, ex: `@hello@mastodon.social`)
* @property {string} [bluesky] - optional Bluesky handle (ex: `@handle.bsky.social`)
* @property {string} [emoji] - some emoji corresponding to the contributor
* @property {'apple' | 'windows' | 'linux' | 'bsd'} [computer]
* @property {'iphone' | 'android' | 'windowsphone' | 'flipphone'} [phone]
@ -9175,7 +9176,7 @@ module.exports = [
description:
'Software engineer by day. Hip-hop, coffee, and street photography aficionado by night.',
url: 'https://kendallmorgan.com/uses',
twitter: '@kendallmorgan',
bluesky: '@kendallmorgan.com',
mastodon: '@kendallmorgan@mastodon.social',
emoji: '☕',
computer: 'apple',