Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import React from "react"
  2. import { Link , graphql , useStaticQuery } from "gatsby"
  3. import Layout from "../components/layout"
  4. import Button from '@material-ui/core/Button';
  5.  
  6. const IndexPage = () => {
  7. const data = useStaticQuery(graphql`
  8. query getPost {
  9. swapi {
  10. posts {
  11. title
  12. description
  13. created_at
  14. id
  15. }
  16. }
  17. }
  18. `)
  19. return (
  20. <Layout>
  21. <Button variant="contained" color="primary">
  22. Hello World
  23. </Button>
  24. {
  25. data.swapi.posts.map(post => <div key={post.id}>
  26. <Link to={`/post/${post.id}`}>
  27. <h1>{post.title}</h1>
  28. </Link>
  29. <h1>{post.description}</h1>
  30. </div>)
  31. }
  32. </Layout>
  33. )
  34. }
  35.  
  36. export default IndexPage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement