Some corrections with types and undeleted file
All checks were successful
Build and Deploy to Web Server / deploy (push) Successful in 18m1s
All checks were successful
Build and Deploy to Web Server / deploy (push) Successful in 18m1s
This commit is contained in:
41
src/components/TextLink.astro
Normal file
41
src/components/TextLink.astro
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
import type { HTMLAttributes } from "astro/types";
|
||||
|
||||
interface Props extends HTMLAttributes<"a"> {
|
||||
includeExternalLinkIcon?: boolean;
|
||||
}
|
||||
|
||||
import { Icon } from "astro-icon/components";
|
||||
|
||||
const {
|
||||
href,
|
||||
class: className,
|
||||
includeExternalLinkIcon = true,
|
||||
...attrs
|
||||
} = Astro.props;
|
||||
|
||||
const linkIsExternal: boolean =
|
||||
href !== undefined && href !== null
|
||||
? href.toString().startsWith("http")
|
||||
: false;
|
||||
---
|
||||
|
||||
<a
|
||||
href={href}
|
||||
class:list={["group text-primary inline-block transition", className]}
|
||||
target={href?.toString().startsWith("http") ? "_blank" : undefined}
|
||||
rel={linkIsExternal ? "noopener noreferrer" : undefined}
|
||||
{...attrs}
|
||||
><span class="group-hover:text-gray-300"><slot /></span>{
|
||||
includeExternalLinkIcon && linkIsExternal && (
|
||||
<sup class="ml-0.5 inline-block">
|
||||
<Icon
|
||||
name="mdi:external-link"
|
||||
class:list={[
|
||||
"text-primary m-0 inline-block group-hover:text-gray-300"
|
||||
]}
|
||||
/>
|
||||
</sup>
|
||||
)
|
||||
}
|
||||
</a>
|
||||
Reference in New Issue
Block a user