Next.js 为 WordPress 加载更多按钮

问题描述

我正在使用这个 Github source code 来测试 Nextjs + wordpress。但它只显示了 20 个家的帖子。我想要的只是加载更多按钮以加载下一个帖子,直到它到达结尾。

这是获取 20 个帖子的 api.js 代码

 export async function getAllPostsForHome(preview) {
  const data = await fetchAPI(
    `
    query AllPosts {
      posts(first: 20,where: { orderby: { field: DATE,order: DESC } }) {
        edges {
          node {
            title
            excerpt
            slug
            date
            featuredImage {
              node {
                sourceUrl
              }
            }
            author {
              node {
                name
                firstName
                lastName
                avatar {
                  url
                }
              }
            }
          }
        }
      }
    }
  `,{
      variables: {
        onlyEnabled: !preview,preview,},}
  )

  return data?.posts
}

那么,我应该怎么做才能在 Index.js 上使用加载更多按钮,以便它继续显示一个帖子,直到没有剩余的帖子要显示为止。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)