我正在尝试从博客文章的前端返回作者图片。前面的内容是这样构造的;
---
title: XXX
date: "XXX"
description: "XXX"
featuredImage: './featured-image.jpg'
avatar: './author.jpg'
author: 'XXX'
---
在 gatsby-config 我有这样的 gatsby-plugin-feed 设置 -
{
resolve: `gatsby-plugin-feed`,
options: {
query: `
{
site {
siteMetadata {
title
author
siteUrl
site_url: siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allMarkdownRemark } }) => {
return allMarkdownRemark.edges.map(edge => {
return Object.assign({}, edge.node.frontmatter, {
description: edge.node.frontmatter.description,
date: edge.node.frontmatter.date,
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
avatar: edge.node.frontmatter.avatar,
custom_elements: [{ "content:encoded": edge.node.html }],
})
})
},
query: `
{
allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] },
) {
edges {
node {
excerpt
html
fields { slug }
frontmatter {
title
date
author
description
avatar
}
}
}
}
}
`,
output: "/rss.xml",
title: "Your Site's RSS Feed",
},
],
},
},
这会导致错误 Error: Field "avatar" of type "File" must have a selection of subfields. Did you mean "avatar { ... }"?
如何更改它以便在 RSS 提要中返回图像 URL?
谢谢