graphql - 如何将帖子链接到作者
问题描述
我正在尝试为每个作者生成一个页面,包括他们的所有帖子 - 这是我的设置:
- 用于
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 查询或一些替代的最佳实践?
谢谢!
解决方案
推荐阅读
- html - How to move scrollbar behind fixed Navbar/Header
- python - 列表理解的优雅总结
- angular - 使用 Ts 文件中的 ngx translate 服务翻译甜蜜警报标题和消息
- python - 在 Google Colab 上运行时出现“系统退出 2”
- javascript - 如何在表格中动态修复工具提示消息ID
- google-cloud-platform - Google Stackdriver Monitoring 用于监控实例组中的每个虚拟机
- java - 如何解决以下描述中描述的错误?
- java - 当应用程序关闭以进行事件提醒时如何生成通知?
- android - 数据库 URL 更改后,Sketchware 无法连接到 Firebase 实时数据库
- python - 树莓派 HC-sr04 远距离控制音量