2024-12-23 21:18:55 +00:00
|
|
|
---
|
|
|
|
import type { HTMLAttributes } from "astro/types";
|
|
|
|
|
|
|
|
interface Props extends HTMLAttributes<"a"> {
|
|
|
|
href: string;
|
|
|
|
}
|
|
|
|
|
2025-05-29 12:19:16 +01:00
|
|
|
const { href, ...rest } = Astro.props;
|
|
|
|
|
|
|
|
const isExternal =
|
|
|
|
/^(https?:)?\/\//.test(href) ||
|
|
|
|
href.startsWith("mailto:") ||
|
|
|
|
href.startsWith("tel:");
|
2024-12-23 21:18:55 +00:00
|
|
|
---
|
|
|
|
|
2025-05-29 12:19:16 +01:00
|
|
|
<a
|
|
|
|
href={href}
|
|
|
|
target={isExternal ? "_blank" : "_self"}
|
|
|
|
rel={isExternal ? "noopener noreferrer" : undefined}
|
|
|
|
{...rest}
|
|
|
|
>
|
2024-12-23 21:18:55 +00:00
|
|
|
<slot />
|
|
|
|
</a>
|