Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions website/app/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -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 (
1 change: 1 addition & 0 deletions website/app/components/Locale.tsx
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ export function Locale() {
<MenuItem key={locale}>
<Link
href={`/${locale}`}
ignoreLocale
className="flex w-full rounded-lg hover:bg-black/5 hover:dark:bg-white/5 px-3 py-1.5 text-sm"
>
{iso639LanguageCodes[locale]}
4 changes: 2 additions & 2 deletions website/app/context.ts
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions website/app/utils.ts
Original file line number Diff line number Diff line change
@@ -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);