conradlin

blogPost.js

May 4th, 2020
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react'
  2. import { graphql } from 'gatsby'
  3. import Layout from '../components/layout'
  4. import { parseImageUrl } from 'notabase/src/utils'
  5.  
  6.  
  7. export default ({ data }) => {
  8.   const { posts: { title, tags, publish_date, html, url, slug, desc, color, cover_image } } = data
  9.  
  10.   return (
  11.     <Layout>
  12.       <div id = "main">
  13.         <div>{tags && tags.join(', ')}</div>
  14.         <h1>{title}</h1>
  15.         <div dangerouslySetInnerHTML={{ __html: html }} />
  16.       </div>
  17.     </Layout>
  18.   )
  19. }
  20.  
  21. export const query = graphql`
  22.   query($slug: String!) {
  23.     posts(slug: { eq: $slug }) {
  24.       html
  25.       title
  26.       tags
  27.       publish_date
  28.       url
  29.       desc
  30.       color
  31.       cover_image
  32.     }
  33.   }
  34. `
Add Comment
Please, Sign In to add comment