export default (contents) => {
  if (contents && contents.length) {
    let first = contents.find(content => content.type !== 'image_url_block');
    if (first && first.type) {
      switch (first.type) {
        case 'text_block':
          return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...';
        // return first.value.text;
        case 'link_block':
          return first.value.url;
        case 'document_block':
          const parts = first.value.url.split('/');
          return parts[parts.length - 1];
        default:
          return '';
      }
    }
  }
  return '';
};
