remove unsupported file types from channel pages

This commit is contained in:
Travis Eden 2018-11-12 15:45:55 -05:00
parent 513484fce4
commit aaa8feb577

View file

@ -3,46 +3,42 @@ import { Link } from 'react-router-dom';
import createCanonicalLink from '../../../../utils/createCanonicalLink'; import createCanonicalLink from '../../../../utils/createCanonicalLink';
const AssetPreview = ({ defaultThumbnail, claimData }) => { const AssetPreview = ({ defaultThumbnail, claimData }) => {
const { name, fileExt, contentType, thumbnail, title } = claimData; const {name, fileExt, contentType, thumbnail, title} = claimData;
const showUrl = createCanonicalLink({ asset: { ...claimData }}); const showUrl = createCanonicalLink({asset: {...claimData}});
const embedUrl = `${showUrl}.${fileExt}`; const embedUrl = `${showUrl}.${fileExt}`;
return ( switch (contentType) {
<Link to={showUrl} className='asset-preview'> case 'image/jpeg':
{(() => { case 'image/jpg':
switch (contentType) { case 'image/png':
case 'image/jpeg': case 'image/gif':
case 'image/jpg': return (
case 'image/png': <Link to={showUrl} className='asset-preview'>
case 'image/gif': <div>
return ( <img
<div> className={'asset-preview-image'}
<img src={embedUrl}
className={'asset-preview-image'} alt={name}
src={embedUrl} />
alt={name} <h3 className='list-title'>{title}</h3>
/> </div>
<h3 className='list-title'>{title}</h3> </Link>
</div> );
); case 'video/mp4':
case 'video/mp4': return (
return ( <Link to={showUrl} className='asset-preview'>
<div> <div>
<img <img
className={'asset-preview-video'} className={'asset-preview-video'}
src={thumbnail || defaultThumbnail} src={thumbnail || defaultThumbnail}
alt={name} alt={name}
/> />
<h3 className='list-title'>{title}</h3> <h3 className='list-title'>{title}</h3>
</div> </div>
); </Link>
default: );
return ( default:
<p>unsupported file type</p> return null;
); }
}
})()}
</Link>
);
}; };
export default AssetPreview; export default AssetPreview;