As described, I would like to add pagination on a page, where I'm fetching data from Sanity.
I'm using getStaticProps
for fetching data, and I know that getStaticProps
works at build time, so how can I add pagination? Should I kind of pre-build pages?
My code looks like this:
export const getStaticProps = async () => {
const textures = await clientSanity.fetch(`*[_type == "texture"] | order(publishedAt desc){
_id,
title,
'slug': slug.current,
mainImage{asset->{_id, url}},
}`);
const categories = await clientSanity.fetch(`*[_type == "category"] | order(title asc){
_id,
title,
'slug': slug.current,
}`);
return {
props: {
textures,
categories,
},
};
};
I really don't know where to start.