【发布时间】:2021-05-25 03:09:01
【问题描述】:
如上所述,我想在从 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,
},
};
};
我真的不知道从哪里开始。
【问题讨论】: