Skip to content

Commit 9ea1b3c

Browse files
Merge pull request #402 from ioveracker/mastodon
2 parents fff5757 + aafab40 commit 9ea1b3c

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

components/Footer.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react'
33
import { FaEnvelopeOpenText } from '@react-icons/all-files/fa/FaEnvelopeOpenText'
44
import { FaGithub } from '@react-icons/all-files/fa/FaGithub'
55
import { FaLinkedin } from '@react-icons/all-files/fa/FaLinkedin'
6+
import { FaMastodon } from '@react-icons/all-files/fa/FaMastodon'
67
import { FaTwitter } from '@react-icons/all-files/fa/FaTwitter'
78
import { FaYoutube } from '@react-icons/all-files/fa/FaYoutube'
89
import { FaZhihu } from '@react-icons/all-files/fa/FaZhihu'
@@ -63,6 +64,17 @@ export const FooterImpl: React.FC = () => {
6364
</a>
6465
)}
6566

67+
{config.mastodon && (
68+
<a
69+
className={styles.mastodon}
70+
href={config.mastodon}
71+
title={`Mastodon ${config.getMastodonHandle()}`}
72+
rel='me'
73+
>
74+
<FaMastodon />
75+
</a>
76+
)}
77+
6678
{config.zhihu && (
6779
<a
6880
className={styles.zhihu}

components/styles.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@
9393
color: #2795e9;
9494
}
9595

96+
.mastodon:hover {
97+
color: #5a4be1;
98+
}
99+
96100
.zhihu:hover {
97101
color: #0066ff;
98102
}

lib/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,24 @@ export const language: string = getSiteConfig('language', 'en')
5555

5656
// social accounts
5757
export const twitter: string | null = getSiteConfig('twitter', null)
58+
export const mastodon: string | null = getSiteConfig('mastodon', null)
5859
export const github: string | null = getSiteConfig('github', null)
5960
export const youtube: string | null = getSiteConfig('youtube', null)
6061
export const linkedin: string | null = getSiteConfig('linkedin', null)
6162
export const newsletter: string | null = getSiteConfig('newsletter', null)
6263
export const zhihu: string | null = getSiteConfig('zhihu', null)
6364

65+
export const getMastodonHandle = (): string | null => {
66+
if (!mastodon) {
67+
return null
68+
}
69+
70+
// Since Mastodon is decentralized, handles include the instance domain name.
71+
// e.g. @example@mastodon.social
72+
const url = new URL(mastodon)
73+
return `${url.pathname.slice(1)}@${url.hostname}`
74+
}
75+
6476
// default notion values for site-wide consistency (optional; may be overridden on a per-page basis)
6577
export const defaultPageIcon: string | null = getSiteConfig(
6678
'defaultPageIcon',

lib/site-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface SiteConfig {
1616
newsletter?: string
1717
youtube?: string
1818
zhihu?: string
19+
mastodon?: string;
1920

2021
defaultPageIcon?: string | null
2122
defaultPageCover?: string | null

site.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default siteConfig({
2020
twitter: 'transitive_bs',
2121
github: 'transitive-bullshit',
2222
linkedin: 'fisch2',
23+
// mastodon: '#', // optional mastodon profile URL, provides link verification
2324
// newsletter: '#', // optional newsletter URL
2425
// youtube: '#', // optional youtube channel name or `channel/UCGbXXXXXXXXXXXXXXXXXXXXXX`
2526

0 commit comments

Comments
 (0)