如何在 markdown frontmatter 中创建字符串列表?

How to create list of strings in markdown frontmatter?

我正在尝试使用 gatsbyjs 和 graphql 从 markdown frontmatter 中以列表的形式检索数据。给定降价文件中的列表,目标是将列表项提取到我的反应组件中以供进一步使用。

这是我的工作,我想使用 GatsbyJS 和 React 创建一个网站(这就是为什么我不能共享真实代码的原因)。 到目前为止,我已经尝试通过 GraphQL 从 frontmatter 简单地获取数据,但是该字段未定义或仅包含 null 值。

我有这样的前言:

---
name: "someName"
expertise: "someExpertise"
...
technologies: 
- tech1
- tech2
- tech3
---

在我的 js 代码中,我尝试像这样使用 graphql 获取数据:

query($slug: String!) {
    profile: markdownRemark(fields: { slug: { eq: $slug } }) {
      html
      frontmatter {
        date(formatString: "DD MMMM, YYYY")
        author
        expertise
        name
        dev_type
        degree 
        technologies
      }
    }
}

我希望输出匹配这样的形式:

technologies = ["tech1", "tech2", "tech3"]

但在开发环境中尝试编译和 运行 站点时出现以下错误:

案例一

Errors:
  Int cannot represent non-integer value: "tech1"

我不知道如何解决这个问题。以我的理解,这应该有效。已经尝试在 gatsby-node.js 中创建名为 technologies 的新 NodeField,但这也没有用。

根据这个frontmatter,我还考虑了另一件事,在我的理解中,frontmatter 是一个YAML,或者更确切地说,markdown 文件中所需的技术列表是一个YAML 列表,不是吗?
在这种情况下,我应该 adjust/extend gatsby-config.js 中的 gatsby-transformer-yaml 插件,但我不知道如何通过 right/correct 方式实现这一目标。

案例2.

不幸的是,我无法再重现我的查询,但我找到了一种方法,我没有得到类型错误,但 technologies 只包含 null 值(具有相同的 frontmatter 内容)。

technologies = [ null, null, null, ...]

发现technologies: [ tech1, tech2, tech3 ]是这个问题的解决方案。实际问题是我的降价文件中提供的数据不一致。