martials.no/src/components/links/ExternalLink.astro
Martin Berg Alstad 4724b0a0e0
Moved some contstants to a constants.ts file.
Added LinkedIn link in footer.

Added option to add icon to ExternalLinks

Refactored some code in ExternalLink.

Signed-off-by: Martin Berg Alstad <git@martials.no>
2024-10-22 20:46:53 +02:00

29 lines
762 B
Plaintext

---
import type { LinkProps } from "@/types/props"
import type { PajamasIcon } from "@/types/icons"
import ExternalLinkTextOnly from "./ExternalLinkTextOnly.astro"
import ExternalLinkIconLeft from "./ExternalLinkIconLeft.astro"
interface Props extends LinkProps {
iconLeft?: PajamasIcon
iconLeftAriaLabel?: string
}
const { iconLeft, iconLeftAriaLabel, ...props } = Astro.props
if (iconLeft && !iconLeftAriaLabel) {
throw new Error("ExternalLink: iconLeftAriaLabel is required when iconLeft is provided")
}
---
{ iconLeft && iconLeftAriaLabel
?
<ExternalLinkIconLeft iconLeft={iconLeft} iconLeftAriaLabel={iconLeftAriaLabel} {...props}>
<slot />
</ExternalLinkIconLeft>
:
<ExternalLinkTextOnly {...props}>
<slot />
</ExternalLinkTextOnly>
}