Add support for Mastodon link in footer

This commit is contained in:
Isaac Overacker
2022-11-12 21:26:41 -08:00
parent fff575728f
commit aafab40f68
5 changed files with 30 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ import * as React from 'react'
import { FaEnvelopeOpenText } from '@react-icons/all-files/fa/FaEnvelopeOpenText'
import { FaGithub } from '@react-icons/all-files/fa/FaGithub'
import { FaLinkedin } from '@react-icons/all-files/fa/FaLinkedin'
import { FaMastodon } from '@react-icons/all-files/fa/FaMastodon'
import { FaTwitter } from '@react-icons/all-files/fa/FaTwitter'
import { FaYoutube } from '@react-icons/all-files/fa/FaYoutube'
import { FaZhihu } from '@react-icons/all-files/fa/FaZhihu'
@@ -63,6 +64,17 @@ export const FooterImpl: React.FC = () => {
</a>
)}
{config.mastodon && (
<a
className={styles.mastodon}
href={config.mastodon}
title={`Mastodon ${config.getMastodonHandle()}`}
rel='me'
>
<FaMastodon />
</a>
)}
{config.zhihu && (
<a
className={styles.zhihu}

View File

@@ -93,6 +93,10 @@
color: #2795e9;
}
.mastodon:hover {
color: #5a4be1;
}
.zhihu:hover {
color: #0066ff;
}

View File

@@ -55,12 +55,24 @@ export const language: string = getSiteConfig('language', 'en')
// social accounts
export const twitter: string | null = getSiteConfig('twitter', null)
export const mastodon: string | null = getSiteConfig('mastodon', null)
export const github: string | null = getSiteConfig('github', null)
export const youtube: string | null = getSiteConfig('youtube', null)
export const linkedin: string | null = getSiteConfig('linkedin', null)
export const newsletter: string | null = getSiteConfig('newsletter', null)
export const zhihu: string | null = getSiteConfig('zhihu', null)
export const getMastodonHandle = (): string | null => {
if (!mastodon) {
return null
}
// Since Mastodon is decentralized, handles include the instance domain name.
// e.g. @example@mastodon.social
const url = new URL(mastodon)
return `${url.pathname.slice(1)}@${url.hostname}`
}
// default notion values for site-wide consistency (optional; may be overridden on a per-page basis)
export const defaultPageIcon: string | null = getSiteConfig(
'defaultPageIcon',

View File

@@ -16,6 +16,7 @@ export interface SiteConfig {
newsletter?: string
youtube?: string
zhihu?: string
mastodon?: string;
defaultPageIcon?: string | null
defaultPageCover?: string | null

View File

@@ -20,6 +20,7 @@ export default siteConfig({
twitter: 'transitive_bs',
github: 'transitive-bullshit',
linkedin: 'fisch2',
// mastodon: '#', // optional mastodon profile URL, provides link verification
// newsletter: '#', // optional newsletter URL
// youtube: '#', // optional youtube channel name or `channel/UCGbXXXXXXXXXXXXXXXXXXXXXX`