Contentful logo

Contentful Community

Pagination for image gallery with Gatsby & Contentful

Hello everyone, I hope you’re doing great :). I have a couple of questions about the proper “structure” of a gallery page.
I’m doing a react-gatsby portfolio website connected to the Contentful. I managed to set the graphql query to pull art from the Contentful API but now I have another problem.
I need to make pagination and sorting for the gallery.
I tried to google for some guides and solutions but I didn’t found anything concrete, only guides I found was for the React without any pulls from API :frowning:
What should I use? I found that gatsby could create pages from a previously made markdown but I don’t know how to fill these pages with art and how to properly move between them.

I will appreciate any advice or help, cause I’m new to React/graphql and Contentful API.

Link to the portfolio page https://5f8a18722047660008f35a1c--mystifying-payne-fe0850.netlify.app/portfolio

Hi @littlegreengoblin

I’m not sure about the implementation in the Gatsby/React code. However, Gatsby usually leverage on its own GraphQL schema (that is slightly different from the GraphQL we provide as Contentful), therefore you should be able to adapt the GraphQL query to do both sorting and pagination, as explained here: