refactor: update site metadata structure

This commit is contained in:
enscribe 2025-03-22 17:21:30 -07:00
parent 71d1df3bd7
commit 931bf7277c
No known key found for this signature in database
GPG key ID: 9BBD5C4114E25322
15 changed files with 123 additions and 114 deletions

View file

@ -1,51 +1,37 @@
---
import Link from '@/components/Link.astro'
import { buttonVariants } from '@/components/ui/button'
import type { Link as SocialLink } from '@/consts'
import { cn } from '@/lib/utils'
import { ICON_MAP } from '@/consts'
import type { SocialLink } from '@/types'
import { Icon } from 'astro-icon/components'
interface Props {
links: SocialLink[]
className?: string
}
const { links, className } = Astro.props
const iconMap = {
Website: 'lucide:globe',
GitHub: 'lucide:github',
LinkedIn: 'lucide:linkedin',
Twitter: 'lucide:twitter',
Email: 'lucide:mail',
RSS: 'lucide:rss',
}
const getSocialLink = ({ href, label }: SocialLink) => ({
href: label === 'Email' ? `mailto:${href}` : href,
ariaLabel: label,
iconName:
iconMap[label as keyof typeof iconMap] || 'lucide:message-circle-question',
})
const { links } = Astro.props
---
<ul class={cn('flex flex-wrap gap-2', className)} role="list">
<ul class="flex flex-wrap gap-2" role="list">
{
links.map((link) => {
const { href, ariaLabel, iconName } = getSocialLink(link)
return (
<li>
<Link
href={href}
aria-label={ariaLabel}
title={ariaLabel}
class={buttonVariants({ variant: 'outline', size: 'icon' })}
external
>
<Icon name={iconName} class="size-4" />
</Link>
</li>
)
})
links.map(({ href, label }) => (
<li>
<Link
href={href}
aria-label={label}
title={label}
class={buttonVariants({ variant: 'outline', size: 'icon' })}
external
>
<Icon
name={
ICON_MAP[label as keyof typeof ICON_MAP] ||
'lucide:message-circle-question'
}
class="size-4"
/>
</Link>
</li>
))
}
</ul>