import { useId, type PropsWithChildren, type ReactNode } from 'react'; import { Tooltip } from 'react-tooltip'; import { RouterLink } from './RouterLink'; import { slottableComponent } from '../HOC/slottableComponent'; type Props = PropsWithChildren<{ href: string; tooltip?: ReactNode }>; export const MarkdownLink = slottableComponent( 'MarkdownLink', ({ href, children, tooltip }) => { const id = useId(); const extraProps = tooltip ? { 'data-tooltip-id': `tooltip-${id}`, className: 'link-md' } : {}; const isAbsoluteLink = href.trim().startsWith('/'); return ( <> {isAbsoluteLink ? ( {children} ) : ( {children} )} {tooltip && ( {tooltip} )} ); } );