Skip to content

Commit 539db5c

Browse files
committed
Automatically add attributes on external true
1 parent b132714 commit 539db5c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/navigation/Link.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,21 @@ type LinkProps = {
3333
& InternalLinkProps
3434
& React.RefAttributes<HTMLAnchorElement>;
3535

36-
const Link = ({ className, color, underline, children, external, hrefLang = "en", ...props }: LinkProps) => {
36+
const Link = ({ className, color, underline, children, external, hrefLang = "en", rel, ...props }: LinkProps) => {
3737

3838
const computedClassName = useMemo(
3939
() => twMerge(style({ color, underline }), className),
4040
[className, color, underline]
4141
);
4242

4343
return (
44-
<InternalLink className={computedClassName} hrefLang={hrefLang} {...props}>
44+
<InternalLink
45+
className={computedClassName}
46+
hrefLang={hrefLang}
47+
rel={`${external ? "external" : ""} ${rel}`}
48+
target={external ? "_blank" : undefined}
49+
{...props}
50+
>
4551
{children}
4652
{external && <ArrowTopRightOnSquareIcon
4753
className="inline w-4 h-4"

0 commit comments

Comments
 (0)