import React from "react"
import { graphql } from "gatsby"
import Layout from "../components/layout"
export default ({ data }) => (
<Layout>
<h1>About {data.site.siteMetadata.title}</h1>
<p>
We're the only site running on your computer dedicated to showing the best
photos and videos of pandas eating lots of food.
</p>
</Layout>
)
export const query = graphql`
query {
site {
siteMetadata {
title
}
}
}
Static Query
Allows non-page components (layout.js), to get data
import React from "react"
import { useStaticQuery, graphql } from "gatsby"
export default ({ children }) => {
const data = useStaticQuery(
graphql`
query {
site {
siteMetadata {
title
}
}
}
`
)
return (
<div>
<h3>
{data.site.siteMetadata.title}
</h3>
{children}
</div>
)
}
Source Plugins
fetch data from sources like: Wordpress
File System
gatsby-source-filesystem basically gets you all local files in your gatsby folder with allFile and file query