Last active
July 18, 2018 21:40
-
-
Save tayiorbeii/6582a654746db7493cd0459e7f404b1e to your computer and use it in GitHub Desktop.
Gatsby StaticQuery Errors
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
// src/pages/index.js | |
import React from 'react' | |
import {StaticQuery, graphql} from 'gatsby' | |
import Layout from '../components/layout' | |
// const HomePage = ({data}) => { | |
// return ( | |
// <Layout> | |
// {data.site.siteMetadata.description} | |
// </Layout> | |
// ) | |
// } | |
const HomePage = () => { | |
return ( | |
<StaticQuery | |
query={graphql` | |
query HomePageQuery { | |
site { | |
siteMetadata { | |
title | |
description | |
} | |
} | |
} | |
`} | |
render={data => <div>{JSON.stringify(data)}</div>} | |
/> | |
) | |
} | |
// export const query = graphql` | |
// query HomepageQuery { | |
// allMarkdownRemark( | |
// sort: {order: DESC, fields: [frontmatter___date]} | |
// ) { | |
// edges { | |
// node { | |
// html | |
// id | |
// frontmatter { | |
// date | |
// path | |
// title | |
// } | |
// } | |
// } | |
// } | |
// site { | |
// siteMetadata { | |
// title | |
// description | |
// } | |
// } | |
// } | |
// ` | |
export default HomePage |
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
// src/pages/index.js | |
import React from 'react' | |
import {StaticQuery, graphql} from 'gatsby' | |
import Layout from '../components/layout' | |
const HomePage = ({data}) => { | |
return ( | |
<Layout> | |
{data.site.siteMetadata.description} | |
</Layout> | |
) | |
} | |
// const HomePage = () => { | |
// return ( | |
// <StaticQuery | |
// query={graphql` | |
// query HomePageQuery { | |
// site { | |
// siteMetadata { | |
// title | |
// description | |
// } | |
// } | |
// } | |
// `} | |
// render={data => <div>{JSON.stringify(data)}</div>} | |
// /> | |
// ) | |
// } | |
export const query = graphql` | |
query HomepageQuery { | |
allMarkdownRemark( | |
sort: {order: DESC, fields: [frontmatter___date]} | |
) { | |
edges { | |
node { | |
html | |
id | |
frontmatter { | |
date | |
path | |
title | |
} | |
} | |
} | |
} | |
site { | |
siteMetadata { | |
title | |
description | |
} | |
} | |
} | |
` | |
export default HomePage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment