关于讨论类别表单的 YAML 语法
可以通过将 YAML 表单定义文件添加到存储库中的 /.github/DISCUSSION_TEMPLATE/ 文件夹来创建自定义讨论类别表单。 如果你不熟悉 YAML 并且想要了解详细信息,请参阅“在 Y 分钟内了解 YAML”。
该名称必须与某个讨论类别的数据域相对应。 例如,“公告”类别的模板应为 .github/DISCUSSION_TEMPLATE/announcements.yml。
对于每个字段,可以定义输入类型、验证和默认标签。
当社区成员填写讨论表单时,他们对每个输入的响应都会转换为 Markdown 并添加到讨论正文中。 社区成员可以编辑使用讨论表单创建的讨论,其他人可以像通过其他方法创建的讨论一样与讨论进行交互。
此示例 YAML 配置文件定义一般讨论类别表单。
title: "[General] "
labels: ["General Introduction"]
body:
  - type: markdown
    attributes:
      value: |
        This is text that will show up in the template!
  - type: textarea
    id: improvements
    attributes:
      label: Top 3 improvements
      description: "What are the top 3 improvements we could make to this project?"
      value: |
        1.
        2.
        3.
        ...
      render: bash
    validations:
      required: true
  - type: markdown
    attributes:
      value: |
        ## Markdown header
        And some more markdown
  - type: input
    id: has-id
    attributes:
      label: Suggestions
      description: A description about suggestions to help you
    validations:
      required: true
  - type: dropdown
    id: download
    attributes:
      label: Which area of this project could be most improved?
      options:
        - Documentation
        - Pull request review time
        - Bug fix time
        - Release cadence
    validations:
      required: true
  - type: checkboxes
    attributes:
      label: Check that box!
      options:
        - label: This one!
          required: true
        - label: I won't stop you if you check this one, too
  - type: markdown
    attributes:
      value: |
        ### The thrilling conclusion
        _to our template_
title: "[General] "
labels: ["General Introduction"]
body:
  - type: markdown
    attributes:
      value: |
        This is text that will show up in the template!
  - type: textarea
    id: improvements
    attributes:
      label: Top 3 improvements
      description: "What are the top 3 improvements we could make to this project?"
      value: |
        1.
        2.
        3.
        ...
      render: bash
    validations:
      required: true
  - type: markdown
    attributes:
      value: |
        ## Markdown header
        And some more markdown
  - type: input
    id: has-id
    attributes:
      label: Suggestions
      description: A description about suggestions to help you
    validations:
      required: true
  - type: dropdown
    id: download
    attributes:
      label: Which area of this project could be most improved?
      options:
        - Documentation
        - Pull request review time
        - Bug fix time
        - Release cadence
    validations:
      required: true
  - type: checkboxes
    attributes:
      label: Check that box!
      options:
        - label: This one!
          required: true
        - label: I won't stop you if you check this one, too
  - type: markdown
    attributes:
      value: |
        ### The thrilling conclusion
        _to our template_
顶级语法
讨论类别表单的配置文件必须包含一个 body 键,并且 body 必须至少包含 1 个非 Markdown 字段。
body:
- type: input
  id: suggestion
  attributes:
    label: Suggestion
    description: "How might we make this project better?"
    placeholder: "Adding a CODE_OF_CONDUCT.md file would be a great idea."
  validations:
    required: true
body:
- type: input
  id: suggestion
  attributes:
    label: Suggestion
    description: "How might we make this project better?"
    placeholder: "Adding a CODE_OF_CONDUCT.md file would be a great idea."
  validations:
    required: true
可以为每个讨论类别表单设置以下顶级键。
| 密钥 | 说明 | 必需 | 类型 | 
|---|---|---|---|
body | 在讨论表单中定义输入类型。 | 必需 | 数组 | 
labels | 将自动添加到此模板创建的讨论的标签。 | 可选 | 阵列或逗号分界的字符串 | 
title | 在讨论提交表单中预填的默认标题。 | 可选 | String | 
若要向表单添加字段,请在 body 键中包含表单元素数组。 有关可用元素及其语法的列表,请参阅 GitHub 表单架构的语法。