Files
tuono/apps/documentation/src/components/mdx-provider/mdx-link/mdx-link.tsx
T

37 lines
844 B
TypeScript
Raw Normal View History

2024-07-27 11:33:34 +02:00
import type { AnchorHTMLAttributes } from 'react'
import { Button } from '@mantine/core'
import { Link } from 'tuono'
import { IconExternalLink } from '@tabler/icons-react'
export default function MdxLink(
props: AnchorHTMLAttributes<HTMLAnchorElement>,
): JSX.Element {
2024-08-16 11:05:49 +02:00
if (props.href?.startsWith('http') || props.href?.startsWith('mailto')) {
2024-07-27 11:33:34 +02:00
return (
<Button
component="a"
{...props}
target="_blank"
rightSection={
<IconExternalLink size="16px" style={{ marginLeft: -5 }} />
}
variant="transparent"
style={{ height: '20px' }}
mt={-2}
p={0}
/>
)
}
return (
<Button
component={Link}
{...props}
target="_blank"
variant="transparent"
style={{ height: '20px' }}
mt={-2}
p={0}
/>
)
}