Files
gitbook/src/components/DocumentView/Link.tsx
T
Samy Pessé 7267398d5b Use caching for search/ask and rich content for answers (#68)
* Use caching for search/ask

* Refactor DocumentView to be ready to be used for other stuff

* Start logic to use document

* Fix comment

* Remove log

* Format and typecheck
2023-12-25 22:59:14 +01:00

29 lines
873 B
TypeScript

import { DocumentInlineLink } from '@gitbook/api';
import NextLink from 'next/link';
import { InlineProps } from './Inline';
import { Inlines } from './Inlines';
export async function Link(props: InlineProps<DocumentInlineLink>) {
const { inline, document, context } = 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} />
</span>
);
}
return (
<NextLink
href={resolved.href}
className="underline underline-offset-2 text-primary hover:text-primary-700 transition-colors "
>
<Inlines context={context} document={document} nodes={inline.nodes} />
</NextLink>
);
}