Skip to content

Commit 2d09404

Browse files
committed
Reapply "fix: Use regular <a> tag for mailto/tel links in Cards component"
This reverts commit ee2b836.
1 parent dcbf357 commit 2d09404

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

components/cards.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import cn from 'clsx'
55
import NextLink from 'next/link'
66
import type { ComponentProps, CSSProperties, ReactNode } from 'react'
77

8+
function CardLink({ href, children, ...props }: { href: string; children: ReactNode; className?: string; [key: string]: any }) {
9+
if (href.startsWith('mailto:') || href.startsWith('tel:')) {
10+
return <a href={href} {...props}>{children}</a>
11+
}
12+
return <NextLink href={href} {...props}>{children}</NextLink>
13+
}
14+
815
const classes = {
916
cards: cn(
1017
'nextra-cards x:mt-4 x:gap-4 x:grid',
@@ -50,7 +57,7 @@ export function Card({
5057

5158
if (image) {
5259
return (
53-
<NextLink
60+
<CardLink
5461
href={href}
5562
className={cn(
5663
classes.card,
@@ -71,12 +78,12 @@ export function Card({
7178
{animatedArrow}
7279
</span>
7380
</span>
74-
</NextLink>
81+
</CardLink>
7582
)
7683
}
7784

7885
return (
79-
<NextLink
86+
<CardLink
8087
href={href}
8188
className={cn(
8289
classes.card,
@@ -95,7 +102,7 @@ export function Card({
95102
<span className="x:block x:-mt-1 x:opacity-60 x:text-sm x:text-left">{description}</span>
96103
{animatedArrow}
97104
</span>
98-
</NextLink>
105+
</CardLink>
99106
)
100107
}
101108

0 commit comments

Comments
 (0)