Hi,
I created pages using an array. And I would like to path letters in context but I doesn't work because it seems I have to use it in GraphQL queries.
What is the solution to use context outside of GraphQL queries, such as props maybe?
Thanks
'abcdefghijklmnopqrstuvwxyz'.split('').map(letter => {
createPage({
path: `definitions/${letter}`,
component: path.resolve('src/templates/definitions.js'),
context: {
letter,
},
});
});
hi the context is being passed as prop automatically. you can use it in your page template like this if you are working with the v2 of gatsby:
const { pathContext } = this.props;
cost { letter } = pathContext;
hi the context is being passed as prop automatically. you can use it in your page template like this if you are working with the v2 of gatsby:
const { pathContext } = this.props;
Perfect, so simple! Thanks @arturhenryy!!
Most helpful comment
hi the context is being passed as prop automatically. you can use it in your page template like this if you are working with the v2 of gatsby:
const { pathContext } = this.props;cost { letter } = pathContext;