短代码参数

描述 Hugo 短代码的参数定义,这对编写短代码文档非常有用。

语法

1{{% hugo/shortcode-params [data] %}}

参数

data

索引名称类型必填默认值版本
#0datastring--

数据文件名。

heading

索引名称类型必填默认值版本
-headingstring-Parameters-

标题。

headingStartLevel

索引名称类型必填默认值版本
-headingStartLevelnumber-2-

开始标题的级别。

数据条目属性

name

名称上下文类型必填默认值版本
name-string--

参数名。

position

名称上下文类型必填默认值版本
position-number---

位置参数的索引。

type

名称上下文类型必填默认值版本
type-string/array-string-

参数类型。

required

名称上下文类型必填默认值版本
required-boolean-false-

表示参数是否必填。

default

名称上下文类型必填默认值版本
default-string---

参数默认值。

since

名称上下文类型必填默认值版本
since-string---

表示添加参数的版本。

description

名称上下文类型必填默认值版本
description-string/object--

参数说明,支持 Markdown。

description.default

名称上下文类型必填默认值版本
description.default-string---

默认的参数说明。

description.[lang]

名称上下文类型必填默认值版本
description.[lang]-string---

特定语言的描述。

options

名称上下文类型必填默认值版本
options-array---

可选项。

deprecated

名称上下文类型必填默认值版本
deprecated-string-false-

表示参数是否已被弃用。

示例

data/example-params.yaml
 1- name: foo
 2  position: 0
 3  required: true
 4  description:
 5    default: Foo description.
 6    zh-hans: Foo 描述。
 7    zh-hant: Foo 描述。
 8
 9- name: bar
10  type: number
11  since: v0.2.0
12  deprecated: true
13  description:
14    default: Bar description.
15    zh-hans: Bar 描述。
16    zh-hant: Bar 描述。
17
18- name: fizz
19  description: Single description without translations.
20  options:
21    - one
22    - two

Result as follows.

1{{% hugo/shortcode-params data="data/example-params.yaml" heading="Example Parameters" headingStartLevel=3 %}}

Example Parameters

foo

索引名称类型必填默认值版本
#0foostring--

Foo 描述。

bar

索引名称类型必填默认值版本
-barnumber--v0.2.0

Bar 描述。

fizz

索引名称类型必填默认值版本
-fizzstring---

Single description without translations.

可选项:one, two