问题描述
我有这个 Gatsby 项目,我想从本地 Yaml 文件中获取内容.我已经安装了 gatsby-transformer-yaml 并且它似乎工作正常,但我的测试文件返回空结果.我不知道为什么.
I've this Gatsby project where I'd like to source the content from local Yaml files. I've installed gatsby-transformer-yaml and it seems to work ok, but my test file is returning null results. I'm not sure why.
这里是文件 hero.yaml 的内容
Here's the content of the file hero.yaml
# hero.yaml
- titulo: Titulo principal.
- subtitulo: Titulo secundário
- botao: Texto do botão
它在我的 graphql IDE 中的结果:
And its results in my graphql IDE:
如您所见,第一项返回正常.不知道其他人发生了什么.任何想法可能是什么?谢谢
As you can see, the first item is returning ok. Not sure what's happening to the others.Any ideas of what could be? Thanks
推荐答案
我发现我的 Yaml 格式有误.每行开始都没有破折号.这是正确的方法.
I figured out that my Yaml formatting was wrong. There's no dash for every line start. Here's the proper way.
# hero.yaml
- titulo: Título principal
subtitulo: Título secundário
botao: Texto do botão
这篇关于Yaml 文件在 Gatsby Graphql 查询中返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!