import { Fragment } from 'react'; import LazyImage from '../lazy-image'; import { MdOpenInNew } from 'react-icons/md'; import { ga, skeleton } from '../../utils'; import { SanitizedExternalProject } from '../../interfaces/sanitized-config'; const ExternalProjectCard = ({ externalProjects, header, loading, googleAnalyticId, }: { externalProjects: SanitizedExternalProject[]; header: string; loading: boolean; googleAnalyticId?: string; }) => { const renderSkeleton = () => { const array = []; for (let index = 0; index < externalProjects.length; index++) { array.push(

{skeleton({ widthCls: 'w-32', heightCls: 'h-8', className: 'mb-2 mx-auto', })}

{skeleton({ widthCls: 'w-full', heightCls: 'h-full', shape: '', })}
{skeleton({ widthCls: 'w-full', heightCls: 'h-4', className: 'mx-auto', })}
{skeleton({ widthCls: 'w-full', heightCls: 'h-4', className: 'mx-auto', })}
, ); } return array; }; const renderExternalProjects = () => { return externalProjects.map((item, index) => ( { e.preventDefault(); try { if (googleAnalyticId) { ga.event('Click External Project', { post: item.title, }); } } catch (error) { console.error(error); } window?.open(item.link, '_blank'); }} >

{item.title}

{item.imageUrl && (
)}

{item.description}

)); }; return (
{loading ? ( skeleton({ widthCls: 'w-12', heightCls: 'h-12', className: 'rounded-xl', }) ) : (
)}

{loading ? skeleton({ widthCls: 'w-40', heightCls: 'h-8' }) : header}

{loading ? skeleton({ widthCls: 'w-32', heightCls: 'h-4' }) : `Showcasing ${externalProjects.length} projects`}
{loading ? renderSkeleton() : renderExternalProjects()}
); }; export default ExternalProjectCard;