首页 > 解决方案 > 在 yaml 文件中添加相同变量名的数组

问题描述

对于这个网站,它从 authors.Yaml 文件中获取信息。

此文件包含演示作者的详细信息。

authors:
  - slug: wutali
    name: Takahiro Fujiwara
    introduction:
      Co-founder and CTO at Fuller, Inc. / Software & Data Engineer /
      Python / Golang / React

但是,我想输入我的信息。

  - slug: Hemming
    name: Alexander Hemming
    introduction:
      Developer, React, Node, Sveltekit, Goland.
    - slug: Owner
    name: John Doe
    introduction:
    Founder and CEO at a company. 

将此添加到末尾似乎不起作用。我如何使其他潜在作者可以访问此信息?

标签: yaml

解决方案


您有两个缩进错误:

  - slug: Hemming
    name: Alexander Hemming
    introduction:
      Developer, React, Node, Sveltekit, Goland.
  - slug: Owner   # fixed indentation to be on par with previous item
    name: John Doe
    introduction: # next line must be more indented to be the value
                  # of this key.
      Founder and CEO at a company.

推荐阅读