短代碼參數

描述 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
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="ln"> 1</span><span class="cl">- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">foo</span><span class="w">

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