关于讨论类别表单的 YAML 语法
您可以通过在仓库的 /.github/DISCUSSION_TEMPLATE/ 文件夹中添加 YAML 表单定义文件来创建自定义的讨论类别表单。如果您是 YAML 新手并想了解更多,请参阅 Y 分钟学会 YAML。
名称必须与您某个讨论类别的 slug 对应。例如,“Announcements”类别的模板应为 .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 | 将在讨论提交表单中预先填充的默认标题。 | 可选 | 字符串 |
要向表单添加字段,请在 body 键中包含一个表单元素数组。有关可用元素及其语法的列表,请参阅 GitHub 表单模式语法。