Skip to content

Commit 966fc01

Browse files
committed
fix external links
1 parent 183c168 commit 966fc01

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tailwind/Link.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
7777

7878
const commonProps = {
7979
ref,
80-
target: isExternal ? "_blank" : undefined,
81-
rel: isExternal ? "noopener" : undefined,
8280
...props,
8381
className: cn(className, { [activeClassName]: isActive }),
8482
href,
@@ -87,6 +85,8 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
8785
if (isExternal) {
8886
return (
8987
<a
88+
target="_blank"
89+
rel="noopener"
9090
onClick={() =>
9191
trackCustomEvent(
9292
customEventOptions ?? {
@@ -114,7 +114,9 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
114114

115115
if (isInternalPdf) {
116116
return (
117-
<a
117+
<NextLink
118+
target="_blank"
119+
rel="noopener"
118120
// disable locale prefixing for internal PDFs
119121
// TODO: add i18n support using a rehype plugin (similar as we do for
120122
// images)
@@ -132,7 +134,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
132134
{...commonProps}
133135
>
134136
{children}
135-
</a>
137+
</NextLink>
136138
)
137139
}
138140

0 commit comments

Comments
 (0)