关于讨论类别表单的 YAML 语法
您可以通过在存储库的 /.github/DISCUSSION_TEMPLATE/
文件夹中添加 YAML 表单定义文件来创建自定义讨论类别表单。如果您不熟悉 YAML 并想了解更多信息,请参阅 "在 Y 分钟内学习 YAML。"。
名称必须与您的一个讨论类别的 slug 相对应。例如,"公告" 类别的模板应为 .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 | 使用此模板创建的讨论将自动添加的标签。 | 可选 | 数组或逗号分隔字符串 |
标题 | 将在讨论提交表单中预先填充的默认标题。 | 可选 | 字符串 |
要向表单添加字段,请在 body
键中包含一个表单元素数组。有关可用元素及其语法的列表,请参阅“GitHub 表单模式语法”。