Files
gitbook/src/components/DocumentView/BlockContentRef.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

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}
/>
);
}