Files
gitbook/src/components/DocumentView/Mention.tsx
T
Samy Pessé d0b92dd408 Improve text displayed in mention for anchor content refs (#287)
* Resolve anchor content reference to the block text for mentions

* Only apply it for mentions/etc, where text is needed

* Handle tabs/expandable

* Rename to resolveAnchorText
2024-03-18 18:16:53 +01:00

20 lines
505 B
TypeScript

import { DocumentInlineMention } from '@gitbook/api';
import { StyledLink } from '@/components/primitives';
import { InlineProps } from './Inline';
export async function Mention(props: InlineProps<DocumentInlineMention>) {
const { inline, context } = props;
const resolved = await context.resolveContentRef(inline.data.ref, {
resolveAnchorText: true,
});
if (!resolved) {
return null;
}
return <StyledLink href={resolved.href}>{resolved.text}</StyledLink>;
}