Skip to content

Commit 1e40746

Browse files
committed
fix href for internal pdfs
1 parent 00dbb0e commit 1e40746

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/components/ui/Link.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AnchorHTMLAttributes, forwardRef } from "react"
2-
import NextLink, { type LinkProps as NextLinkProps } from "next/link"
2+
import NextLink from "next/link"
33
import { RxExternalLink } from "react-icons/rx"
44
import { VisuallyHidden } from "@radix-ui/react-visually-hidden"
55

@@ -11,6 +11,7 @@ import * as url from "@/lib/utils/url"
1111
import { DISCORD_PATH, SITE_URL } from "@/lib/constants"
1212

1313
import { useRtlFlip } from "@/hooks/useRtlFlip"
14+
import { Link as I18nLink } from "@/i18n/routing"
1415
import { usePathname } from "@/i18n/routing"
1516

1617
type BaseProps = {
@@ -22,7 +23,7 @@ type BaseProps = {
2223

2324
export type LinkProps = BaseProps &
2425
AnchorHTMLAttributes<HTMLAnchorElement> &
25-
Omit<NextLinkProps, "href">
26+
Omit<typeof I18nLink, "href">
2627

2728
/**
2829
* Link wrapper which handles:
@@ -67,7 +68,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
6768
// Get proper download link for internally hosted PDF's & static files (ex: whitepaper)
6869
// Opens in separate window.
6970
if (isInternalPdf) {
70-
href = getRelativePath(pathname, href)
71+
href = "/" + getRelativePath(pathname, href)
7172
}
7273

7374
if (isDiscordInvite) {
@@ -117,10 +118,6 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
117118
<NextLink
118119
target="_blank"
119120
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}
124121
onClick={() =>
125122
trackCustomEvent(
126123
customEventOptions ?? {
@@ -160,7 +157,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
160157
}
161158

162159
return (
163-
<NextLink
160+
<I18nLink
164161
onClick={() =>
165162
trackCustomEvent(
166163
customEventOptions ?? {
@@ -174,7 +171,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
174171
{...commonProps}
175172
>
176173
{children}
177-
</NextLink>
174+
</I18nLink>
178175
)
179176
})
180177
BaseLink.displayName = "BaseLink"

0 commit comments

Comments
 (0)