import Link from 'next/link'; import ta from 'time-ago'; import { string, bool } from 'prop-types'; const PostLink = ({ href, date, lang, download, children }) => { const link = (
{ date && ( { `${ta.ago(date)} (${date})` } ) } { lang && `(${lang}) ` } { children }
); if (download) { return link; } return ( { link } ); }; PostLink.propTypes = { href: string.isRequired, date: string, lang: string, download: bool }; PostLink.defaultProps = { download: false }; export default PostLink;