mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-04 04:25:28 +00:00
28 lines
612 B
TypeScript
28 lines
612 B
TypeScript
import cx from 'classnames';
|
|
|
|
import type { FunctionalComponent, JSX } from 'preact';
|
|
|
|
interface Props extends JSX.HTMLAttributes<HTMLAnchorElement> {}
|
|
|
|
export const Link: FunctionalComponent<Props> = ({
|
|
class: className,
|
|
children,
|
|
href = '#',
|
|
...props
|
|
}: Props) => {
|
|
const isExternal = (href as string).startsWith('http');
|
|
const classes = cx('link', { external: isExternal }, className as string);
|
|
|
|
return (
|
|
<a
|
|
class={classes}
|
|
href={href}
|
|
rel={isExternal ? 'nofollow noopener noreferrer' : undefined}
|
|
target={isExternal ? '_blank' : undefined}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</a>
|
|
);
|
|
};
|