feat(blog): Add author social icons for bluesky, mastodon, threads, twitch, youtube, instagram (#10768)

Co-authored-by: sebastien <lorber.sebastien@gmail.com>
Co-authored-by: Chas Emerick <chas@cemerick.com>
This commit is contained in:
Zed Spencer-Milnes 2024-12-27 11:32:25 +00:00 committed by GitHub
parent cc97d66dbb
commit 43795fcabb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 364 additions and 17 deletions

View file

@ -15,14 +15,27 @@ describe('normalizeSocials', () => {
linkedin: 'ozakione',
github: 'ozakione',
stackoverflow: 'ozakione',
threads: 'gingergeekuk',
bluesky: 'gingergeek.co.uk',
instagram: 'thisweekinreact',
twitch: 'gingergeek',
youtube: 'gingergeekuk',
mastodon: 'Mastodon',
};
// eslint-disable-next-line jest/no-large-snapshots
expect(normalizeSocials(socials)).toMatchInlineSnapshot(`
{
"bluesky": "https://bsky.app/profile/gingergeek.co.uk",
"github": "https://github.com/ozakione",
"instagram": "https://www.instagram.com/thisweekinreact",
"linkedin": "https://www.linkedin.com/in/ozakione/",
"mastodon": "https://mastodon.social/@Mastodon",
"stackoverflow": "https://stackoverflow.com/users/ozakione",
"threads": "https://www.threads.net/@gingergeekuk",
"twitch": "https://twitch.tv/gingergeek",
"twitter": "https://twitter.com/ozakione",
"youtube": "https://youtube.com/@gingergeekuk",
}
`);
});
@ -33,13 +46,19 @@ describe('normalizeSocials', () => {
linkedIn: 'ozakione',
gitHub: 'ozakione',
STACKoverflow: 'ozakione',
instaGRam: 'thisweekinreact',
BLUESKY: 'gingergeek.co.uk',
tHrEaDs: 'gingergeekuk',
};
expect(normalizeSocials(socials)).toMatchInlineSnapshot(`
{
"bluesky": "https://bsky.app/profile/gingergeek.co.uk",
"github": "https://github.com/ozakione",
"instagram": "https://www.instagram.com/thisweekinreact",
"linkedin": "https://www.linkedin.com/in/ozakione/",
"stackoverflow": "https://stackoverflow.com/users/ozakione",
"threads": "https://www.threads.net/@gingergeekuk",
"twitter": "https://twitter.com/ozakione",
}
`);
@ -62,12 +81,14 @@ describe('normalizeSocials', () => {
linkedin: 'ozakione',
github: 'https://github.com/ozakione',
stackoverflow: 'https://stackoverflow.com/ozakione',
mastodon: 'https://hachyderm.io/@hachyderm',
};
expect(normalizeSocials(socials)).toMatchInlineSnapshot(`
{
"github": "https://github.com/ozakione",
"linkedin": "https://www.linkedin.com/in/ozakione/",
"mastodon": "https://hachyderm.io/@hachyderm",
"stackoverflow": "https://stackoverflow.com/ozakione",
"twitter": "https://twitter.com/ozakione",
}

View file

@ -21,6 +21,12 @@ export const AuthorSocialsSchema = Joi.object<AuthorSocials>({
.try(Joi.number(), Joi.string())
.custom((val) => String(val)),
x: Joi.string(),
bluesky: Joi.string(),
instagram: Joi.string(),
threads: Joi.string(),
mastodon: Joi.string(),
twitch: Joi.string(),
youtube: Joi.string(),
}).unknown();
type PredefinedPlatformNormalizer = (value: string) => string;
@ -35,6 +41,12 @@ const PredefinedPlatformNormalizers: Record<
linkedin: (handle: string) => `https://www.linkedin.com/in/${handle}/`,
stackoverflow: (userId: string) =>
`https://stackoverflow.com/users/${userId}`,
bluesky: (handle: string) => `https://bsky.app/profile/${handle}`,
instagram: (handle: string) => `https://www.instagram.com/${handle}`,
threads: (handle: string) => `https://www.threads.net/@${handle}`,
mastodon: (handle: string) => `https://mastodon.social/@${handle}`, // can be in format user@other.server and it will redirect if needed
twitch: (handle: string) => `https://twitch.tv/${handle}`,
youtube: (handle: string) => `https://youtube.com/@${handle}`, // https://support.google.com/youtube/answer/6180214?hl=en
};
type SocialEntry = [string, string];

View file

@ -46,7 +46,13 @@ declare module '@docusaurus/plugin-content-blog' {
| 'github'
| 'linkedin'
| 'stackoverflow'
| 'x';
| 'x'
| 'bluesky'
| 'instagram'
| 'threads'
| 'mastodon'
| 'youtube'
| 'twitch';
/**
* Social platforms of the author.