Files
gitbook/src/components/DocumentView/InlineLink.tsx
T
Samy Pessé ff773233dd Prevent click on images in links to zoom it (#324)
* Prevent click on images in links to zoom it

* Fix TS
2024-03-22 16:56:08 +01:00

39 lines
1.1 KiB
TypeScript

import { DocumentInlineLink } from '@gitbook/api';
import { InlineProps } from './Inline';
import { Inlines } from './Inlines';
import { Link } from '../primitives';
export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
const { inline, document, context, ancestorInlines } = props;
const resolved = await context.resolveContentRef(inline.data.ref);
if (!resolved) {
return (
<span title="Broken link" className="underline">
<Inlines
context={context}
document={document}
nodes={inline.nodes}
ancestorInlines={[...ancestorInlines, inline]}
/>
</span>
);
}
return (
<Link
href={resolved.href}
className="underline underline-offset-2 text-primary hover:text-primary-700 transition-colors "
>
<Inlines
context={context}
document={document}
nodes={inline.nodes}
ancestorInlines={[...ancestorInlines, inline]}
/>
</Link>
);
}