diff --git a/website/app/components/Link.tsx b/website/app/components/Link.tsx index e4bddb5b..dc6a3f6b 100644 --- a/website/app/components/Link.tsx +++ b/website/app/components/Link.tsx @@ -3,10 +3,12 @@ import type { ComponentProps } from "react"; import { useHref } from "~/context"; import { isExternalLink } from "~/utils"; -type LinkProps = ComponentProps<"a">; +type LinkProps = { + ignoreLocale?: boolean; +} & ComponentProps<"a">; export function Link(props: LinkProps) { - const href = useHref(props.href ?? ""); + const href = useHref(props.href ?? "", props.ignoreLocale); if (isExternalLink(props.href ?? "")) { return ( diff --git a/website/app/components/Locale.tsx b/website/app/components/Locale.tsx index 4378d4dc..7f7fd0f8 100644 --- a/website/app/components/Locale.tsx +++ b/website/app/components/Locale.tsx @@ -46,6 +46,7 @@ export function Locale() { {iso639LanguageCodes[locale]} diff --git a/website/app/context.ts b/website/app/context.ts index 61eb2f04..a8a91828 100644 --- a/website/app/context.ts +++ b/website/app/context.ts @@ -116,9 +116,9 @@ export function useSidebar(): SidebarGroup[] { } // Resolves a path to a full URL. -export function useHref(path: string): string { +export function useHref(path: string, ignoreLocale: boolean = false): string { const ctx = usePageContext(); - return getHref(ctx, path); + return getHref(ctx, path, ignoreLocale); } // Returns the active tab for the current page. diff --git a/website/app/utils.ts b/website/app/utils.ts index 8a2971e1..5a7a1bd2 100644 --- a/website/app/utils.ts +++ b/website/app/utils.ts @@ -175,8 +175,8 @@ export function getLocale(ctx: Context) { // If the path is external, it is returned as is. // If we're in preview mode, the path is prefixed with `/preview`. // Otherwise applies the owner, repository, ref and locale to the path. -export function getHref(ctx: Context, path: string) { - const locale = getLocale(ctx); +export function getHref(ctx: Context, path: string, ignoreLocale: boolean = false) { + const locale = ignoreLocale ? undefined : getLocale(ctx); // Ensures a path, e.g. foo/bar becomes /foo/bar let normalizedPath = ensureLeadingSlash(path);