2024-09-25 22:20:47 +02:00
|
|
|
---
|
2024-10-06 13:27:18 +02:00
|
|
|
import type { LinkProps } from "@/types/props"
|
2024-10-22 20:46:53 +02:00
|
|
|
import type { PajamasIcon } from "@/types/icons"
|
|
|
|
import ExternalLinkTextOnly from "./ExternalLinkTextOnly.astro"
|
|
|
|
import ExternalLinkIconLeft from "./ExternalLinkIconLeft.astro"
|
|
|
|
|
2024-10-06 13:27:18 +02:00
|
|
|
interface Props extends LinkProps {
|
2024-10-22 20:46:53 +02:00
|
|
|
iconLeft?: PajamasIcon
|
|
|
|
iconLeftAriaLabel?: string
|
2024-09-25 22:20:47 +02:00
|
|
|
}
|
|
|
|
|
2024-10-22 20:46:53 +02:00
|
|
|
const { iconLeft, iconLeftAriaLabel, ...props } = Astro.props
|
|
|
|
if (iconLeft && !iconLeftAriaLabel) {
|
|
|
|
throw new Error("ExternalLink: iconLeftAriaLabel is required when iconLeft is provided")
|
|
|
|
}
|
2024-09-25 22:20:47 +02:00
|
|
|
---
|
|
|
|
|
2024-10-22 20:46:53 +02:00
|
|
|
{ iconLeft && iconLeftAriaLabel
|
|
|
|
?
|
|
|
|
<ExternalLinkIconLeft iconLeft={iconLeft} iconLeftAriaLabel={iconLeftAriaLabel} {...props}>
|
2024-09-25 22:20:47 +02:00
|
|
|
<slot />
|
2024-10-22 20:46:53 +02:00
|
|
|
</ExternalLinkIconLeft>
|
|
|
|
:
|
|
|
|
<ExternalLinkTextOnly {...props}>
|
|
|
|
<slot />
|
|
|
|
</ExternalLinkTextOnly>
|
|
|
|
}
|
|
|
|
|