Advertisement
conradlin

postItem.js (with cover image)

May 4th, 2020
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react"
  2. import { Link } from "gatsby"
  3. import { parseImageUrl } from 'notabase/src/utils'
  4.  
  5. export default ({ data }) => {
  6.     const { title, tags, cover_image, publish_date, desc, read_time, url, slug } = data
  7.     let coverimageURL = parseImageUrl(cover_image[0], 1000)
  8.  
  9.     return (
  10.         <div style={{ margin: 10 }}>        
  11.             <Link to={`blog/posts/${url}/`}>
  12.               <img
  13.                 alt={`${title} cover image`}
  14.                 style={{ width: '100%' }}
  15.                 src={coverimageURL}
  16.               />
  17.               <div style = {{color: "grey"}}>Tags: {tags && tags.join(', ')} • Published: {publish_date}{read_time} MIN READ</div>
  18.               <h2>{title}</h2>
  19.               <p style = {{ color: "black" }} dangerouslySetInnerHTML={{ __html: desc }}></p>
  20.             </Link>
  21.         </div>
  22.     )
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement