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
28 lines
734 B
TypeScript
28 lines
734 B
TypeScript
import { DocumentBlockContentRef } from '@gitbook/api';
|
|
|
|
import { Card, Emoji } from '@/components/primitives';
|
|
|
|
import { BlockProps } from './Block';
|
|
|
|
export async function BlockContentRef(props: BlockProps<DocumentBlockContentRef>) {
|
|
const { block, context, style } = props;
|
|
const kind = block?.data?.ref?.kind;
|
|
|
|
const resolved = await context.resolveContentRef(block.data.ref, {
|
|
resolveAnchorText: true,
|
|
});
|
|
if (!resolved) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Card
|
|
leadingIcon={resolved.emoji ? <Emoji code={resolved.emoji} /> : null}
|
|
href={resolved.href}
|
|
preTitle={kind}
|
|
title={resolved.text}
|
|
style={style}
|
|
/>
|
|
);
|
|
}
|