如何将帖子链接到作者

我正在尝试为每个作者(包括他们的所有帖子)生成一个页面-这是我的设置:

  • 使用gatsby-transformer-yaml获取我的作者列表:
    {
      allAuthorsYaml {
        nodes {
          id
          title
        }
      }
    }
  • 使用gatsby-transformer-remark获取我的帖子列表:
    {
      allFile(
        sort: { fields: childMarkdownRemark___frontmatter___date,order: DESC }
        filter: { sourceInstanceName: { eq: "posts" } }
      ) {
        edges {
          node {
            childMarkdownRemark {
              frontmatter {
                author {
                  title
                  id
                }
                date
                location
                title
                slug
                tags
              }
              html
            }
          }
        }
      }
    }
  • 我的author节点已在我的frontmatter中成功地在我的gatsby-config.js中映射:
...
  mapping: {
    "MarkdownRemark.frontmatter.author": `AuthorsYaml`
  },...

现在,我想做的就是使用以下方法获取所有作者的帖子列表:

    {
      allAuthorsYaml {
        nodes {
          id
          title
          posts {
            frontmatter {
              date
              location
              title
              slug
              tags
            }
            html
          }
        }
      }
    }

实现此目标的最有效方法是什么-遵循建议的GraphQL查询或一些替代的最佳做法?

谢谢!

q00120994 回答:如何将帖子链接到作者

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2849799.html

大家都在问