Use Font Awesome icons for hero social links
This commit is contained in:
@@ -1,9 +1,62 @@
|
||||
import { siteConfig } from '@/lib/config';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import {
|
||||
faGithub,
|
||||
faTwitter,
|
||||
faMastodon,
|
||||
faGitAlt,
|
||||
faLinkedin
|
||||
} from '@fortawesome/free-brands-svg-icons';
|
||||
import { faEnvelope } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
export function Hero() {
|
||||
const { name, tagline, social } = siteConfig;
|
||||
const initial = name?.charAt(0)?.toUpperCase() || 'G';
|
||||
|
||||
const items = [
|
||||
social.github && {
|
||||
key: 'github',
|
||||
href: social.github,
|
||||
label: 'GitHub',
|
||||
icon: faGithub
|
||||
},
|
||||
social.twitter && {
|
||||
key: 'twitter',
|
||||
href: `https://twitter.com/${social.twitter.replace('@', '')}`,
|
||||
label: 'Twitter',
|
||||
icon: faTwitter
|
||||
},
|
||||
social.mastodon && {
|
||||
key: 'mastodon',
|
||||
href: social.mastodon,
|
||||
label: 'Mastodon',
|
||||
icon: faMastodon
|
||||
},
|
||||
social.gitea && {
|
||||
key: 'gitea',
|
||||
href: social.gitea,
|
||||
label: 'Gitea',
|
||||
icon: faGitAlt
|
||||
},
|
||||
social.linkedin && {
|
||||
key: 'linkedin',
|
||||
href: social.linkedin,
|
||||
label: 'LinkedIn',
|
||||
icon: faLinkedin
|
||||
},
|
||||
social.email && {
|
||||
key: 'email',
|
||||
href: `mailto:${social.email}`,
|
||||
label: 'Email',
|
||||
icon: faEnvelope
|
||||
}
|
||||
].filter(Boolean) as {
|
||||
key: string;
|
||||
href: string;
|
||||
label: string;
|
||||
icon: any;
|
||||
}[];
|
||||
|
||||
return (
|
||||
<section className="mb-8 rounded-xl border bg-gradient-to-r from-slate-50 to-slate-100 px-6 py-6 shadow-sm dark:border-slate-800 dark:from-slate-900 dark:to-slate-950">
|
||||
<div className="flex items-center gap-4">
|
||||
@@ -17,71 +70,20 @@ export function Hero() {
|
||||
<p className="mt-1 max-w-2xl text-sm text-slate-700 dark:text-slate-100">
|
||||
{tagline}
|
||||
</p>
|
||||
{(social.github ||
|
||||
social.twitter ||
|
||||
social.linkedin ||
|
||||
social.email ||
|
||||
social.mastodon ||
|
||||
social.gitea) && (
|
||||
<div className="mt-2 flex flex-wrap items-center gap-3 text-xs text-slate-500">
|
||||
{social.github && (
|
||||
{items.length > 0 && (
|
||||
<div className="mt-3 flex flex-wrap items-center gap-3 text-xs text-slate-500">
|
||||
{items.map((item) => (
|
||||
<a
|
||||
href={social.github}
|
||||
key={item.key}
|
||||
href={item.href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="rounded-full bg-white/70 px-3 py-1 shadow-sm ring-1 ring-slate-200 hover:bg-slate-50 dark:bg-slate-900/60 dark:ring-slate-700"
|
||||
className="flex items-center gap-2 rounded-full bg-white/80 px-3 py-1 shadow-sm ring-1 ring-slate-200 hover:bg-slate-50 dark:bg-slate-900/80 dark:ring-slate-700"
|
||||
>
|
||||
GitHub
|
||||
<FontAwesomeIcon icon={item.icon} className="h-3.5 w-3.5" />
|
||||
<span>{item.label}</span>
|
||||
</a>
|
||||
)}
|
||||
{social.twitter && (
|
||||
<a
|
||||
href={`https://twitter.com/${social.twitter.replace('@', '')}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="rounded-full bg-white/70 px-3 py-1 shadow-sm ring-1 ring-slate-200 hover:bg-slate-50 dark:bg-slate-900/60 dark:ring-slate-700"
|
||||
>
|
||||
Twitter
|
||||
</a>
|
||||
)}
|
||||
{social.mastodon && (
|
||||
<a
|
||||
href={social.mastodon}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="rounded-full bg-white/70 px-3 py-1 shadow-sm ring-1 ring-slate-200 hover:bg-slate-50 dark:bg-slate-900/60 dark:ring-slate-700"
|
||||
>
|
||||
Mastodon
|
||||
</a>
|
||||
)}
|
||||
{social.gitea && (
|
||||
<a
|
||||
href={social.gitea}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="rounded-full bg-white/70 px-3 py-1 shadow-sm ring-1 ring-slate-200 hover:bg-slate-50 dark:bg-slate-900/60 dark:ring-slate-700"
|
||||
>
|
||||
Gitea
|
||||
</a>
|
||||
)}
|
||||
{social.linkedin && (
|
||||
<a
|
||||
href={social.linkedin}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="rounded-full bg-white/70 px-3 py-1 shadow-sm ring-1 ring-slate-200 hover:bg-slate-50 dark:bg-slate-900/60 dark:ring-slate-700"
|
||||
>
|
||||
LinkedIn
|
||||
</a>
|
||||
)}
|
||||
{social.email && (
|
||||
<a
|
||||
href={`mailto:${social.email}`}
|
||||
className="rounded-full bg-white/70 px-3 py-1 shadow-sm ring-1 ring-slate-200 hover:bg-slate-50 dark:bg-slate-900/60 dark:ring-slate-700"
|
||||
>
|
||||
Email
|
||||
</a>
|
||||
)}
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user