import type {PortableTextBlock} from '../types' export const richText = (content: PortableTextBlock[]): string => { let title = '' const textBlocks = content.filter((blocks) => blocks._type === 'block') if (textBlocks.length) { title = textBlocks .map(({children: _children}) => { const children = Array.isArray(_children) ? _children : [_children] return children .filter(({text}) => text) .map(({text}) => text) .join(' ') }) .join(' ') } return title }