将分页添加到Next.js&;Sanity.io页面
如前所述,我想在页面上添加分页,从Sanity获取数据。 我正在使用将分页添加到Next.js&;Sanity.io页面,next.js,sanity,Next.js,Sanity,如前所述,我想在页面上添加分页,从Sanity获取数据。 我正在使用getStaticProps获取数据,我知道getStaticProps在构建时工作,所以如何添加分页?我应该预先构建页面吗 我的代码如下所示: export const getStaticProps = async () => { const textures = await clientSanity.fetch(`*[_type == "texture"] | order(publishedAt
getStaticProps
获取数据,我知道getStaticProps
在构建时工作,所以如何添加分页?我应该预先构建页面吗
我的代码如下所示:
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,
},
};
};
我真的不知道从哪里开始。对于分页提要,在同一页面上加载更多项目,我遵循的模式是使用SSG加载初始CMS负载,然后在客户端进行分页 这里可以找到一个快速而肮脏的SSR示例: 这也适用于SSG