【发布时间】:2021-01-31 15:25:13
【问题描述】:
我正在尝试在我的 Gatsby 博客上添加特色图片,但无法成功。我尝试了在这里和那里找到的几件事,但我一直收到此错误消息:Field "featuredImage" must not have a selection since type "String" has no subfields.
这是我的博客结构:
src
|- images
|- house.jpeg
| - pages
|- actualites
|- house.mdx
我的house.mdx 有以下主要内容:
---
title: House
path: /house
date: 2019-01-29
featuredImage: ../../images/house.jpeg
---
我的gatsby-plugin 看起来像这样:
plugins: [
`gatsby-plugin-resolve-src`,
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/pages`,
},
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 800,
},
},
],
},
},
{
resolve: `gatsby-plugin-mdx`,
options: {
gatsbyRemarkPlugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 1200,
},
},
],
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
],
我不知道我做错了什么... http://localhost:8000/___graphql 显示了我的featuredImage,但没有显示图像的子字段,所以我猜它不明白我的领域是图像。
你能帮我指出我缺少什么吗?
谢谢你????
【问题讨论】:
-
您是否尝试过添加
name? gatsbyjs.com/plugins/gatsby-source-filesystem -
是的,我试过了。但它并没有改变任何东西,所以我删除了它。