import { h } from 'preact'; import PropTypes from 'prop-types'; const BodyPreview = ({ previewResponse, version, articleState }) => (
{titleArea(version, articleState, previewResponse)}
); function titleArea(version, articleState, previewResponse) { if (version === 'help') { // possibly something different here in future. return ''; } const tagArray = previewResponse.tags || articleState.tagList.split(', '); let tags = '' if (tagArray.length > 0 && tagArray[0].length > 0) { tags = tagArray.map(tag => { return ( {tag.length > 0 ?
{tag}
: ''} {' '}
); }); } let coverImage = '' if (previewResponse.cover_image && previewResponse.cover_image.length > 0) { coverImage =
cover image
} else if (articleState.mainImage) { coverImage =
cover image
} const previewTitle = previewResponse.title || articleState.title || ''; return (
{coverImage}

44 ? 'articleform_titlepreviewsmall' : '' }>{previewTitle}

image   {window.currentUser.name}

{tags}
); } BodyPreview.propTypes = { previewResponse: PropTypes.object.isRequired, articleState: PropTypes.object.isRequired, version: PropTypes.string.isRequired, }; export default BodyPreview;