【发布时间】:2020-03-20 04:24:05
【问题描述】:
我已成功使用gatsby-source-contentful 获取数据,但无法弄清楚如何使用markdownRemark 扩展内容查询,如官方gatsby-contentful-starter 所示。
我在gatsby-config.js 中添加了gatsby-transformer-remark,运行gatsby clean && gatsby develop,但在Graphiql 中仍然看不到childMarkdownRemark。
gatsby-config.js:
module.exports = {
siteMetadata: {
title: 'Test Contentful and MarkdownRemark',
},
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
// spaceId: 'XXXXXXXXXXXX',
// accessToken: 'XXXXXXXXXXXX',
},
},
`gatsby-transformer-remark`
],
}
package.json:
{
"name": "test-gatsby-contentful",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"gatsby": "^2.18.2",
"gatsby-source-contentful": "^2.1.62",
"gatsby-transformer-remark": "^2.6.37"
}
}
【问题讨论】:
-
我尝试了您的存储库,一切正常:我可以查询 childMarkdownRemark。你的内容数据是 Markdown 格式吗?
-
是的,有内容的返回降价。你是否也能在 Graphiql 中看到
body上的childMarkdownRemark? -
是的,我只检查了那里
-
你能分享一下对你有用的查询吗?
-
好吧,我正在使用带有 Markdown 作为外观的长文本(默认一个)
标签: graphql markdown gatsby contentful