Skip to content

Commit bd3edff

Browse files
committed
fix: use react-router link component
1 parent d4820e8 commit bd3edff

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

packages/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"lucide-react": "0.556.0",
1919
"react": "19.1.2",
2020
"react-dom": "19.1.2",
21+
"react-router": "7.9.4",
2122
"shiki": "3.19.0",
2223
"tailwind-merge": "3.4.0",
2324
"tailwind-variants": "3.2.2",

packages/docs/src/page-cloud/CloudHeroBanner/CloudHeroBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const CloudHeroBanner: FC<unknown> = () => (
1111
</Body>
1212
<HStack className={['gap-8', 'mt-16']}>
1313
<Button variant="primary" size="lg" asChild={true}>
14-
<Link href="https://app.composify.cloud" plain={true}>
14+
<Link href="https://app.composify.cloud" target="_blank" plain={true}>
1515
Start free ›
1616
</Link>
1717
</Button>
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ComponentProps, FC } from 'react';
2+
import { Link as RouterLink } from 'react-router';
23
import type { VariantProps } from 'tailwind-variants';
34
import { variants } from './LinkVariants';
45

@@ -7,6 +8,12 @@ type Props = Omit<ComponentProps<'a'>, 'className'> &
78
className?: string[];
89
};
910

10-
export const Link: FC<Props> = ({ className, plain, href, ...props }) => (
11-
<a className={variants({ className, plain })} href={href} {...props} />
12-
);
11+
export const Link: FC<Props> = ({ className, plain, href, ...props }) => {
12+
const isExternal = href?.match(/^(https?:|mailto:|tel:)/);
13+
14+
if (isExternal) {
15+
return <a className={variants({ className, plain })} href={href} {...props} />;
16+
}
17+
18+
return <RouterLink className={variants({ className, plain })} to={href ?? ''} {...props} />;
19+
};

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)