I want to map my export in GraphQL, instead of repeat my images 3 times, check my code to understand me.
this is my export :
export default [
{
id: Math.random(),
imageUrl: require("../../images/recent-game/1.jpg"),
},
{
id: Math.random(),
imageUrl: require("../../images/recent-game/2.jpg"),
},
{
id: Math.random(),
imageUrl: require("../../images/recent-game/3.jpg"),
},
]
This is my import and GraphQL
import BackgroundImage from "gatsby-background-image"
import { useStaticQuery, graphql } from "gatsby"
const getData = graphql`
{
image1: file(relativePath: { eq: "recent-game/1.jpg" }) {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
image2: file(relativePath: { eq: "recent-game/2.jpg" }) {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
image3: file(relativePath: { eq: "recent-game/3.jpg" }) {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
}
`
Here i want to map my images instead of repeating them, depending on my export