import PropTypes from 'prop-types'; import { h, Fragment } from 'preact'; import { formatDate } from './util'; import ExternalLinkIcon from '@images/external-link.svg'; export const SingleArticle = ({ id, title, publishedAt, cachedTagList, nthPublishedByAuthor, user, key, articleOpened, path, toggleArticle, }) => { const activateToggle = () => toggleArticle(id, title, path); const tagsFormat = (tag, key) => { if (tag) { return ( # {tag} ); } }; const tags = cachedTagList.split(', ').map((tag) => tagsFormat(tag, key)); const newAuthorNotification = nthPublishedByAuthor <= 3 ? '👋 ' : ''; return (

{title}

{tags}
{newAuthorNotification} {user.name}
); }; SingleArticle.propTypes = { id: PropTypes.number.isRequired, title: PropTypes.string.isRequired, path: PropTypes.string.isRequired, publishedAt: PropTypes.string.isRequired, cachedTagList: PropTypes.isRequired, user: PropTypes.isRequired, key: PropTypes.number.isRequired, };