mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
22 lines
563 B
TypeScript
22 lines
563 B
TypeScript
import {forwardRef} from 'react';
|
|
|
|
import Anchor from './anchor';
|
|
|
|
export interface ExternalLinkProps
|
|
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'target'> {
|
|
disabled?: boolean;
|
|
openInNewTab?: boolean;
|
|
}
|
|
|
|
const ExternalLink = forwardRef<HTMLAnchorElement, ExternalLinkProps>(
|
|
({openInNewTab = true, ...props}, ref) => {
|
|
const anchorProps = openInNewTab
|
|
? {target: '_blank', rel: 'noreferrer noopener'}
|
|
: {href: props.href};
|
|
|
|
return <Anchor ref={ref} {...anchorProps} {...props} />;
|
|
}
|
|
);
|
|
|
|
export default ExternalLink;
|