import { BlockProps } from './Block'; import { ContentRefContext, resolveContentRef } from '@/lib/references'; import { ClassValue, tcls } from '@/lib/tailwind'; import { getNodeFragmentByName, isNodeEmpty } from '@/lib/document'; import { Inlines } from './Inlines'; import { DocumentBlockImage, DocumentBlockImages } from '@gitbook/api'; export function Images(props: BlockProps) { const { block, style, context } = props; return (
{block.nodes.map((node: any, i: number) => ( 0 && 'mt-4', style]} siblings={block.nodes.length} context={context} /> ))}
); } async function ImageBlock(props: { block: DocumentBlockImage; style: ClassValue; context: ContentRefContext; siblings: number; }) { const { block, context, siblings } = props; const [src, darkSrc] = await Promise.all([ resolveContentRef(block.data.ref, context), block.data.refDark ? resolveContentRef(block.data.refDark, context) : null, ]); if (!src) { return null; } const caption = getNodeFragmentByName(block, 'caption'); const image = {block.data.alt}; if (!caption || isNodeEmpty(caption)) { return image; } return ( {image}
); }