PostCard.jsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import defaultPhoto from '../../materials/default-photo.png'
  2. import { Link } from 'react-router-dom'
  3. import galery from '../../materials/gallery-icon.png'
  4. export const Card = ({ post }) => (
  5. <>
  6. <Link key={post?._id} to={`/post/${post?._id}`}>
  7. {
  8. post?.images && post?.images.length > 1 ?
  9. (
  10. <div className='Wrapper'>
  11. <img src={galery} style={{
  12. position: 'fixed',
  13. right: '0',
  14. zIndex:'2',
  15. top: '0',
  16. width: '50px', height: '50px',
  17. margin:'10px'
  18. }} />
  19. <img
  20. className="Card"
  21. src={'/' + post.images[0].url}
  22. style={{
  23. width: '250px',
  24. height: '250px',
  25. objectFit: 'cover',
  26. position:'relative'
  27. }}
  28. />
  29. </div>)
  30. :
  31. post?.images && post?.images[0] && post.images[0]?.url ? (
  32. <div className='Wrapper'>
  33. <img
  34. className="Card"
  35. src={'/' + post.images[0].url}
  36. style={{
  37. width: '250px',
  38. height: '250px',
  39. objectFit: 'cover',
  40. }}
  41. />
  42. </div>
  43. ) : (
  44. <div className='Wrapper'>
  45. <img
  46. className="Card"
  47. src={defaultPhoto}
  48. style={{
  49. width: '250px',
  50. height: '250px',
  51. objectFit: 'cover',
  52. }}
  53. />
  54. </div>
  55. )
  56. }
  57. </Link>
  58. </>
  59. )