diff --git a/.env.local.example b/.env.local.example index 36b709d..255cef8 100644 --- a/.env.local.example +++ b/.env.local.example @@ -10,6 +10,7 @@ NEXT_PUBLIC_SITE_AUTHOR="Your Name" NEXT_PUBLIC_SITE_TAGLINE="Short tagline for your blog." NEXT_PUBLIC_POSTS_PER_PAGE="5" NEXT_PUBLIC_DEFAULT_LOCALE="zh-TW" +NEXT_PUBLIC_SITE_AVATAR_URL="https://www.gravatar.com/avatar/yourhash?s=160&d=identicon" # Social and profile NEXT_PUBLIC_TWITTER_HANDLE="@yourhandle" diff --git a/components/right-sidebar.tsx b/components/right-sidebar.tsx index 4def051..3b0dbfe 100644 --- a/components/right-sidebar.tsx +++ b/components/right-sidebar.tsx @@ -1,83 +1,152 @@ import Link from 'next/link'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faGithub, faMastodon, faLinkedin } from '@fortawesome/free-brands-svg-icons'; import { siteConfig } from '@/lib/config'; import { getAllPostsSorted, getAllTagsWithCount } from '@/lib/posts'; +import { allPages } from 'contentlayer/generated'; export function RightSidebar() { const latest = getAllPostsSorted().slice(0, 5); const tags = getAllTagsWithCount().slice(0, 5); + const aboutPage = + allPages.find((p) => p.title.includes('關於作者')) ?? + allPages.find((p) => p.slug === 'about-me'); + + const avatarSrc = siteConfig.avatar; + + const socialItems = [ + siteConfig.social.github && { + key: 'github', + href: siteConfig.social.github, + icon: faGithub, + label: 'GitHub' + }, + siteConfig.social.mastodon && { + key: 'mastodon', + href: siteConfig.social.mastodon, + icon: faMastodon, + label: 'Mastodon' + }, + siteConfig.social.linkedin && { + key: 'linkedin', + href: siteConfig.social.linkedin, + icon: faLinkedin, + label: 'LinkedIn' + } + ].filter(Boolean) as { key: string; href: string; icon: any; label: string }[]; + return ( ); diff --git a/lib/config.ts b/lib/config.ts index d7fdb8e..f9b5e44 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -14,6 +14,7 @@ export const siteConfig = { ? Number(process.env.NEXT_PUBLIC_POSTS_PER_PAGE) : 5, defaultLocale: process.env.NEXT_PUBLIC_DEFAULT_LOCALE || 'zh-TW', + avatar: process.env.NEXT_PUBLIC_SITE_AVATAR_URL || '', social: { twitter: process.env.NEXT_PUBLIC_TWITTER_HANDLE || '', github: process.env.NEXT_PUBLIC_GITHUB_URL || '',