mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 19:32:07 +00:00
7267398d5b
* 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
29 lines
873 B
TypeScript
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>
|
|
);
|
|
}
|