Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将分页添加到Next.js&;Sanity.io页面_Next.js_Sanity - Fatal编程技术网

将分页添加到Next.js&;Sanity.io页面

将分页添加到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

如前所述,我想在页面上添加分页,从Sanity获取数据。 我正在使用
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