mirror of
https://github.com/BradNut/awesome-uses
synced 2025-09-08 17:40:31 +00:00
Added Mastodon handling
This commit is contained in:
parent
7979e7f7a9
commit
8c54dac35e
6 changed files with 29 additions and 6 deletions
1
.github/pull_request_template.md
vendored
1
.github/pull_request_template.md
vendored
|
|
@ -18,6 +18,7 @@ Include the hardware you use, such as your computer and other related equipment.
|
||||||
* Ensure this PR has a title in the following format
|
* Ensure this PR has a title in the following format
|
||||||
* ✅ Add Your Name
|
* ✅ Add Your Name
|
||||||
* ✅ Add @twitterusername
|
* ✅ Add @twitterusername
|
||||||
|
* ✅ Add @mastodonusername@instance.url
|
||||||
* ❌ Add myself
|
* ❌ Add myself
|
||||||
* ❌ Adding myself!
|
* ❌ Adding myself!
|
||||||
* ❌ Add Your Name @twitter @github
|
* ❌ Add Your Name @twitter @github
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ Include the hardware you use, such as your computer and other related equipment.
|
||||||
* Ensure this PR has a title in the following format
|
* Ensure this PR has a title in the following format
|
||||||
* ✅ Add Your Name
|
* ✅ Add Your Name
|
||||||
* ✅ Add @twitterusername
|
* ✅ Add @twitterusername
|
||||||
|
* ✅ Add @mastodonusername@instance.url
|
||||||
* ❌ Add myself
|
* ❌ Add myself
|
||||||
* ❌ Adding myself!
|
* ❌ Adding myself!
|
||||||
* ❌ Add Your Name @twitter @github
|
* ❌ Add Your Name @twitter @github
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ module.exports.Schema = Joi.object({
|
||||||
.valid(...flags)
|
.valid(...flags)
|
||||||
.required(),
|
.required(),
|
||||||
twitter: Joi.string().pattern(new RegExp(/^@?(\w){1,15}$/)),
|
twitter: Joi.string().pattern(new RegExp(/^@?(\w){1,15}$/)),
|
||||||
|
mastodon: Joi.string().pattern(new RegExp(/^@(\w){1,30}@(\w)+\.(\w)+$/)),
|
||||||
emoji: Joi.string().allow(''),
|
emoji: Joi.string().allow(''),
|
||||||
computer: Joi.string().valid('apple', 'windows', 'linux', 'bsd'),
|
computer: Joi.string().valid('apple', 'windows', 'linux', 'bsd'),
|
||||||
phone: Joi.string().valid('iphone', 'android', 'windowsphone', 'flipphone'),
|
phone: Joi.string().valid('iphone', 'android', 'windowsphone', 'flipphone'),
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ export default function Person({ person }) {
|
||||||
const twitter = person.twitter
|
const twitter = person.twitter
|
||||||
? `https://unavatar.io/${person.twitter.replace('@', '')}`
|
? `https://unavatar.io/${person.twitter.replace('@', '')}`
|
||||||
: null;
|
: null;
|
||||||
|
const mastodonArr = person.mastodon
|
||||||
|
? person.mastodon.replace('@', '').split('@')
|
||||||
|
: null;
|
||||||
const website = `https://unavatar.io/${url.host}`;
|
const website = `https://unavatar.io/${url.host}`;
|
||||||
const unavatar = person.twitter
|
const unavatar = person.twitter
|
||||||
? `${twitter}?fallback=${website}&ttl=28d`
|
? `${twitter}?fallback=${website}&ttl=28d`
|
||||||
|
|
@ -81,15 +84,23 @@ export default function Person({ person }) {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{person.twitter && (
|
{person.twitter || person.mastodon && (
|
||||||
<div className="TwitterHandle">
|
<div className="SocialHandle">
|
||||||
<a
|
<a
|
||||||
href={`https://twitter.com/${person.twitter.replace('@', '')}`}
|
href={
|
||||||
|
person.twitter
|
||||||
|
? `https://twitter.com/${person.twitter.replace('@', '')}`
|
||||||
|
: `https://${mastodonArr[1]}/@${mastodonArr[0]}`
|
||||||
|
}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<span className="at">@</span>
|
<span className="at">@</span>
|
||||||
{person.twitter.replace('@', '')}
|
{
|
||||||
|
person.twitter
|
||||||
|
? person.twitter.replace('@', '')
|
||||||
|
: `${mastodonArr[1]}/@${mastodonArr[0]}`
|
||||||
|
}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
@ -113,7 +124,15 @@ Person.propTypes = {
|
||||||
if (!/^@?(\w){1,15}$/.test(props[propName])) {
|
if (!/^@?(\w){1,15}$/.test(props[propName])) {
|
||||||
return new Error(
|
return new Error(
|
||||||
`Invalid prop \`${propName}\` supplied to` +
|
`Invalid prop \`${propName}\` supplied to` +
|
||||||
` \`${componentName}\`. This isn't a legit twitter handle.`
|
` \`${componentName}\`. This isn't a legit Twitter handle.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mastodon(props, propName, componentName) {
|
||||||
|
if (!/^@(\w){1,30}@(\w)+\.(\w)+$/.test(props[propName])) {
|
||||||
|
return new Error(
|
||||||
|
`Invalid prop \`${propName}\` supplied to` +
|
||||||
|
` \`${componentName}\`. This isn't a legit Mastodon handle.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
* @property {string} url - link to contributor's /uses page
|
* @property {string} url - link to contributor's /uses page
|
||||||
* @property {string} country - flag emoji for contributor's country
|
* @property {string} country - flag emoji for contributor's country
|
||||||
* @property {string} [twitter] - optional Twitter username (beginning with `@`)
|
* @property {string} [twitter] - optional Twitter username (beginning with `@`)
|
||||||
|
* @property {string} [mastodon] - optional Twitter username (beginning with `@`)
|
||||||
* @property {string} [emoji] - some emoji corresponding to the contributor
|
* @property {string} [emoji] - some emoji corresponding to the contributor
|
||||||
* @property {'apple' | 'windows' | 'linux' | 'bsd'} [computer]
|
* @property {'apple' | 'windows' | 'linux' | 'bsd'} [computer]
|
||||||
* @property {'iphone' | 'android' | 'windowsphone' | 'flipphone'} [phone]
|
* @property {'iphone' | 'android' | 'windowsphone' | 'flipphone'} [phone]
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ body::-webkit-scrollbar-thumb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.TwitterHandle {
|
.SocialHandle {
|
||||||
font-size: 1.24323423426928098420394802rem;
|
font-size: 1.24323423426928098420394802rem;
|
||||||
& .at {
|
& .at {
|
||||||
color: var(--yellow);
|
color: var(--yellow);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue