【问题标题】:In Gatsby starter blog, how to increase number of latest posts from 3 to 20 in home page在 Gatsby 入门博客中,如何将主页中的最新帖子数量从 3 增加到 20
【发布时间】:2020-03-18 05:02:43
【问题描述】:

我开始使用 Gatsby Minimal Starter Blog by LekoArtsGithub repo。目前首页只能显示3个最新帖子。我能知道如何将它从 3 增加到 30。我没有看到任何设置。

【问题讨论】:

    标签: reactjs gatsby


    【解决方案1】:

    homepage-query.tsx的graphql查询中定义:

    export const query = graphql`
      query($formatString: String!) {
        allPost(sort: { fields: date, order: DESC }, limit: 3) {
          nodes {
            slug
            title
            date(formatString: $formatString)
            excerpt
            timeToRead
            description
            tags {
              name
              slug
            }
          }
        }
      }
    `
    

    gatsby-node.jsgatsby-theme-minimal-blog-core 中使用(一个依赖项)。

    const homepageTemplate = require.resolve(`./src/templates/homepage-query.tsx`)
    

    【讨论】:

      猜你喜欢
      • 2020-07-24
      • 1970-01-01
      • 2020-01-13
      • 2021-06-30
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 2014-01-14
      • 1970-01-01
      相关资源
      最近更新 更多