mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
d0b92dd408
* 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
20 lines
505 B
TypeScript
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>;
|
|
}
|