Created
July 13, 2019 11:36
-
-
Save luandevpro/e0e731c921c8d0e7bf170ece86f85719 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React , { useEffect , useState } from "react" | |
import { Link , graphql , useStaticQuery ,navigate } from "gatsby" | |
import Layout from "../components/layout" | |
import Button from '@material-ui/core/Button'; | |
import slugify from "../utils/slugify" | |
import withFirebase from "../lib/withFirebase" | |
const IndexPage = (props) => { | |
const [email,setEmail] = useState(null); | |
const data = useStaticQuery(graphql` | |
query getPost { | |
swapi { | |
posts { | |
post_tags { | |
id | |
tag { | |
id | |
name | |
} | |
} | |
title | |
description | |
created_at | |
id | |
} | |
} | |
} | |
`) | |
return ( | |
<Layout> | |
{props.user && props.user.email} | |
<Button variant="contained" color="primary" | |
onClick={() => props.firebase && props.firebase.auth.signInWithPopup(props.firebase.googleAuthProvider)}> | |
Hello World | |
</Button> | |
{ | |
data.swapi.posts.map(post => <div key={post.id}> | |
<Link to={`/post/${post.id}`}> | |
<h1>{post.title}</h1> | |
</Link> | |
<h1>{post.description}</h1> | |
<div> | |
{ | |
post.post_tags.map(tag => ( | |
<Link to={`/tags/${slugify(tag.tag.name)}`}> | |
<span> | |
<b>{tag.tag.name}</b> | |
</span> | |
</Link> | |
)) | |
} | |
</div> | |
</div>) | |
} | |
</Layout> | |
) | |
} | |
export default withFirebase(IndexPage) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment