Skip to content

Instantly share code, notes, and snippets.

@duffn
Last active April 26, 2020 14:09
Show Gist options
  • Save duffn/5c3d76ff15b373af191f0d46b8ed1ff6 to your computer and use it in GitHub Desktop.
Save duffn/5c3d76ff15b373af191f0d46b8ed1ff6 to your computer and use it in GitHub Desktop.
Gatsby YAML Recipe Files
[
{
"name": "Leia Organa",
"profession": "Princess"
},
{
"name": " Luke Skywalker",
"profession": "Jedi Knight"
},
{
"name": "Han Solo",
"profession": "Nerf Herder"
}
]
---
- name: Leia Organa
profession: Princess
- name: Luke Skywalker
profession: Jedi Knight
- name: Han Solo
profession: Nerf Herder
import React from "react"
import { graphql } from "gatsby"
const TestPage = ({ data }) => (
<div>
<ul>
{data.allTestDataJson.nodes.map((node, index) => (
<li key={index}>
{node.name} - {node.profession}
</li>
))}
</ul>
</div>
)
export const query = graphql`
query TestPageQuery {
allTestDataJson {
nodes {
name
profession
}
}
}
`
export default TestPage
import React from "react"
import { graphql } from "gatsby"
const TestPage = ({ data }) => (
<div>
<ul>
{data.allTestDataYaml.nodes.map((node, index) => (
<li key={index}>
{node.name} - {node.profession}
</li>
))}
</ul>
</div>
)
export const query = graphql`
query TestPageQuery {
allTestDataYaml {
nodes {
name
profession
}
}
}
`
export default TestPage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment