Files
website-astro-stefanimhoff.de/src/components/Link.astro
2026-01-20 13:16:24 +01:00

21 lines
505 B
Plaintext

---
interface Props {
class?: string;
href?: string;
[key: string]: any;
}
const { class: className, href = '#', ...props } = Astro.props;
const isExternal = (href as string).startsWith('http');
---
<a
class:list={['link', { external: isExternal }, className]}
data-umami-event={isExternal ? `Link: ${href.replace(/^(https?:\/\/)/, '')}` : undefined}
href={href}
rel={isExternal ? 'nofollow noopener noreferrer' : undefined}
target={isExternal ? '_blank' : undefined}
{...props}><slot /></a
>