Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import React from 'react'
  2. import { Link , StaticQuery, graphql } from "gatsby"
  3. import Layout from "./layout"
  4.  
  5. export default ({data,...props}) => {
  6. console.log(props)
  7. return (
  8. <Layout>
  9. <h1>{data.post.title}</h1>
  10. <p>{data.post.description}</p>
  11. <h1><code>Thao luan ve gatsby</code></h1>
  12. <div>
  13. {
  14. data.allComment.nodes.map(cmt => (
  15. <div key={cmt.id}>
  16. <h2>{cmt.comment}</h2>
  17. <p>{cmt.user.displayName}</p>
  18. </div>
  19. ))
  20. }
  21. </div>
  22. </Layout>
  23. )
  24. }
  25.  
  26. export const query = graphql`
  27. query Post($slug: StringQueryOperatorInput){
  28. post(id: $slug) {
  29. id
  30. title
  31. description
  32. user {
  33. photoURL
  34. displayName
  35. }
  36. }
  37. allComment(filter: {post: {id: $slug}}, limit: 5,sort: {fields: createdAt, order: DESC}) {
  38. totalCount
  39. nodes {
  40. id
  41. comment
  42. user {
  43. displayName
  44. photoURL
  45. }
  46. }
  47. }
  48. }
  49. `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement