Advertisement
conradlin

blog.js

May 4th, 2020
892
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 PostItem from "../components/postItem"
  4. import Layout from '../components/layout'
  5.  
  6. const Blog = (props) => {
  7.   const { data: { allPosts } } = props
  8.   return (
  9.     <Layout>
  10.       <div id= "main">
  11.         {
  12.           allPosts.nodes.map(node => <PostItem data={node} />)
  13.         }
  14.       </div>
  15.     </Layout>
  16.   )
  17. }
  18.  
  19. export default Blog
  20. export const query = graphql`
  21.   query {
  22.     allPosts(filter: {status: {eq: "published"}, content_type: {eq: "article"}}  sort: { fields: [publish_date], order: DESC }) {
  23.       nodes {
  24.         title
  25.         tags
  26.         desc
  27.         content_type
  28.         status
  29.         url
  30.         read_time
  31.         cover_image
  32.         slug
  33.         publish_date(fromNow: false)
  34.       }
  35.     }
  36.   }
  37. `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement