1
1
import { AnchorHTMLAttributes , forwardRef } from "react"
2
- import NextLink , { type LinkProps as NextLinkProps } from "next/link"
2
+ import NextLink from "next/link"
3
3
import { RxExternalLink } from "react-icons/rx"
4
4
import { VisuallyHidden } from "@radix-ui/react-visually-hidden"
5
5
@@ -11,6 +11,7 @@ import * as url from "@/lib/utils/url"
11
11
import { DISCORD_PATH , SITE_URL } from "@/lib/constants"
12
12
13
13
import { useRtlFlip } from "@/hooks/useRtlFlip"
14
+ import { Link as I18nLink } from "@/i18n/routing"
14
15
import { usePathname } from "@/i18n/routing"
15
16
16
17
type BaseProps = {
@@ -22,7 +23,7 @@ type BaseProps = {
22
23
23
24
export type LinkProps = BaseProps &
24
25
AnchorHTMLAttributes < HTMLAnchorElement > &
25
- Omit < NextLinkProps , "href" >
26
+ Omit < typeof I18nLink , "href" >
26
27
27
28
/**
28
29
* Link wrapper which handles:
@@ -67,7 +68,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
67
68
// Get proper download link for internally hosted PDF's & static files (ex: whitepaper)
68
69
// Opens in separate window.
69
70
if ( isInternalPdf ) {
70
- href = getRelativePath ( pathname , href )
71
+ href = "/" + getRelativePath ( pathname , href )
71
72
}
72
73
73
74
if ( isDiscordInvite ) {
@@ -117,10 +118,6 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
117
118
< NextLink
118
119
target = "_blank"
119
120
rel = "noopener"
120
- // disable locale prefixing for internal PDFs
121
- // TODO: add i18n support using a rehype plugin (similar as we do for
122
- // images)
123
- locale = { false }
124
121
onClick = { ( ) =>
125
122
trackCustomEvent (
126
123
customEventOptions ?? {
@@ -160,7 +157,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
160
157
}
161
158
162
159
return (
163
- < NextLink
160
+ < I18nLink
164
161
onClick = { ( ) =>
165
162
trackCustomEvent (
166
163
customEventOptions ?? {
@@ -174,7 +171,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
174
171
{ ...commonProps }
175
172
>
176
173
{ children }
177
- </ NextLink >
174
+ </ I18nLink >
178
175
)
179
176
} )
180
177
BaseLink . displayName = "BaseLink"
0 commit comments