Use local Link wrapper with cloud-mode prefetch default
This commit is contained in:
1 parent
0b4d8040b7
commit
1b6fc1bd51
31 files changed
+43
-31
No files matched your search
@@ -1,17 +1,18 @@
|
||||
import { Icon, Row, Text } from '@umami/react-zen';
|
||||
import Link, { type LinkProps } from 'next/link';
|
||||
import Link, { type LinkProps } from '@/components/common/Link';
|
||||
import type { ReactNode } from 'react';
|
||||
import { ExternalLink as LinkIcon } from '@/components/icons';
|
||||
|
||||
export function ExternalLink({
|
||||
href,
|
||||
children,
|
||||
prefetch = false,
|
||||
...props
|
||||
}: LinkProps & { href: string; children: ReactNode }) {
|
||||
return (
|
||||
<Row alignItems="center" overflow="hidden" gap>
|
||||
<Text title={href} truncate>
|
||||
<Link {...props} href={href} target="_blank">
|
||||
<Link {...props} href={href} target="_blank" prefetch={prefetch}>
|
||||
{children}
|
||||
</Link>
|
||||
</Text>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Icon, Row, Text } from '@umami/react-zen';
|
||||
import Link from 'next/link';
|
||||
import Link from '@/components/common/Link';
|
||||
import { type HTMLAttributes, type ReactNode, useState } from 'react';
|
||||
import { useMessages, useNavigation } from '@/components/hooks';
|
||||
import { ExternalLink } from '@/components/icons';
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import NextLink from 'next/link';
|
||||
import { type ComponentPropsWithoutRef, forwardRef } from 'react';
|
||||
|
||||
export type LinkProps = ComponentPropsWithoutRef<typeof NextLink>;
|
||||
const cloudMode = !!process.env.cloudMode;
|
||||
|
||||
const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link({ prefetch, ...props }, ref) {
|
||||
return <NextLink ref={ref} prefetch={cloudMode ? (prefetch ?? false) : prefetch} {...props} />;
|
||||
});
|
||||
|
||||
export default Link;
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Button, type ButtonProps } from '@umami/react-zen';
|
||||
import Link from 'next/link';
|
||||
import Link from '@/components/common/Link';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useLocale } from '@/components/hooks';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Column, Heading, Row, Text } from '@umami/react-zen';
|
||||
import Link from 'next/link';
|
||||
import Link from '@/components/common/Link';
|
||||
import { IconLabel } from '@/components/common/IconLabel';
|
||||
|
||||
interface NavMenuData {
|
||||
|
||||
Reference in new issue
Block a user