4.1 主题简码


主题简码 的子部分

1.1 徽章(badge)


徽章(badge)简码用于在文本中显示小标记,颜色、标题和图标,可调整。

重要 版本6.6.6 船长 信息新增 超棒!

用法

{{% badge %}}重要{{% /badge %}}
{{% badge style="primary" title="版本" %}}6.6.6{{% /badge %}}
{{% badge style="red" icon="angle-double-up" %}}船长{{% /badge %}}
{{% badge style="info" %}}新增{{% /badge %}}
{{% badge color="fuchsia" icon="fab fa-hackerrank" %}}超棒{{% /badge %}}

参数

名称注释
style徽章使用的样式方案。

- 严重程度: info, note, tip, warning
- 印记颜色:primary, secondary, accent
- 颜色: blue, green, grey, orange, red
- 特殊颜色: default, transparent, code
color要使用的 CSS 颜色值。如果未设置,则选择的颜色取决于样式。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的漂亮颜色
- 对于所有其他样式:相应的颜色
title屏幕提醒标题的任意文本。根据样式的不同,可能会有一个默认标题。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的标题
- 对于所有其他样式:<空>

如果您不希望严重性样式的标题,则必须将此参数设置为" "(一个充满空格的非空字符串)。
iconFont Awesome icon name 设置在标题的左侧。根据样式的不同,可能会有一个默认图标。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的漂亮图标
- 对于所有其他样式:<空>

如果您不想为严重性样式使用图标,则必须将此参数设置为" "(填充空格的非空字符串)
<txt>任意文本,可以为 <空>

案例

样式

严重性样式

{{% badge style="info" %}}New{{% /badge %}}
{{% badge style="note" %}}Change{{% /badge %}}
{{% badge style="tip" %}}Optional{{% /badge %}}
{{% badge style="warning" %}}Breaking{{% /badge %}}
信息New 注释Change 提示Optional 警告Breaking

印记样式

{{% badge style="primary" icon="bullhorn" title="Announcement" %}}命令{{% /badge %}}
{{% badge style="secondary" icon="bullhorn" title="Announcement" %}}选项{{% /badge %}}
{{% badge style="accent" icon="bullhorn" title="Announcement" %}}专辑{{% /badge %}}
公告命令 公告选项 公告专辑

颜色样式

{{% badge style="blue" icon="palette" title="Color" %}}蓝色{{% /badge %}}
{{% badge style="green" icon="palette" title="Color" %}}绿色{{% /badge %}}
{{% badge style="grey" icon="palette" title="Color" %}}灰色{{% /badge %}}
{{% badge style="orange" icon="palette" title="Color" %}}橘色{{% /badge %}}
{{% badge style="red" icon="palette" title="Color" %}}红色{{% /badge %}}
Color蓝色 Color绿色 Color灰色 Color橘色 Color红色

特殊颜色

{{% badge style="default" icon="palette" title="Color" %}}默认色{{% /badge %}}
{{% badge style="transparent" icon="palette" title="Color" %}}透明色{{% /badge %}}
Color默认色 Color透明色

变体

没有图标和标题

{{% badge %}}6.6.6{{% /badge %}}
{{% badge style="info" icon=" " title=" " %}}Awesome{{% /badge %}}
{{% badge style="red" %}}Captain{{% /badge %}}
6.6.6 Awesome Captain

没有图标

{{% badge title="Version" %}}6.6.6{{% /badge %}}
{{% badge style="info" icon=" " %}}Awesome{{% /badge %}}
{{% badge style="red" title="Rank" %}}Captain{{% /badge %}}
Version6.6.6 信息Awesome RankCaptain

没有标题

{{% badge icon="star" %}}6.6.6{{% /badge %}}
{{% badge style="info" title=" " %}}Awesome{{% /badge %}}
{{% badge style="red" icon="angle-double-up" %}}Captain{{% /badge %}}
6.6.6 Awesome Captain

有标题和图标

{{% badge icon="star" title="Version" %}}6.6.6{{% /badge %}}
{{% badge style="info" %}}Awesome{{% /badge %}}
{{% badge style="red" icon="angle-double-up" title="Rank" %}}Captain{{% /badge %}}
Version6.6.6 信息Awesome RankCaptain

1.2 按钮(button)


按钮(button)简码显示一个可点击的按钮,颜色、标题和图标可调整。

Get Hugo Get Hugo

用法

{{% button href="https://gohugo.io/" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="warning" icon="dragon" %}}Get Hugo{{% /button %}}

单击该按钮后,它将为给定的 URL 打开另一个浏览器选项卡。

参数

名称默认描述
href链接地址
styletransparent徽章使用的样式方案。

- 严重程度: info, note, tip, warning
- 印记颜色:primary, secondary, accent
- 颜色: blue, green, grey, orange, red
- 特殊颜色: default, transparent, code
color要使用的 CSS 颜色值。如果未设置,则选择的颜色取决于样式。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的漂亮颜色
- 对于所有其他样式:相应的颜色
iconFont Awesome icon name 设置在标题的左侧。根据样式的不同,可能会有一个默认图标。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的漂亮图标
- 对于所有其他样式:<空>

如果您不想为严重性样式使用图标,则必须将此参数设置为" "(填充空格的非空字符串)
iconpositionleft设置图标的位置。

- left :图标在标题的左侧。
- right:图标在标题的右侧。
target如果 href 是 URL,则为目标框架/窗口。否则,不使用该参数。这的行为类似于普通链接。如果未给出该参数,则默认为:
- 设置externalLinkTarget _blank如果未设置,则适用于任何以http://https://
- 所有其他链接没有特定值
type如果 hrefJavaScript,则按钮类型。否则,不使用该参数。如果未给出该参数,则默认为button
<txt>按钮标题的任意文本。根据样式的不同,可能会有一个默认标题。任何给定值都将覆盖默认值。

- 对于严重性样式:严重性
- 对于所有其他样式的匹配标题:<空>

如果不希望严重性样式的标题,则必须将此参数设置为" "(充满空格的非空字符串)

案例

样式

严重性

{{% button href="https://gohugo.io/" style="info" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="note" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="tip" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="warning" %}}Get Hugo{{% /button %}}

Get Hugo Get Hugo Get Hugo Get Hugo

印记颜色

{{% button href="https://gohugo.io/" style="primary" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="secondary" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="accent" %}}Get Hugo{{% /button %}}
Get Hugo Get Hugo Get Hugo

颜色

{{% button href="https://gohugo.io/" style="blue" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="green" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="grey" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="orange" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="red" %}}Get Hugo{{% /button %}}
Get Hugo Get Hugo Get Hugo Get Hugo Get Hugo

特殊颜色

{{% button href="https://gohugo.io/" style="default" %}}Get Hugo{{% /button %}}
{{% button href="https://gohugo.io/" style="transparent" %}}Get Hugo{{% /button %}}
Get Hugo Get Hugo

图标

{{% button href="https://gohugo.io/" icon=" " %}}{{% /button %}}

{{% button href="https://gohugo.io/" icon="download" %}}{{% /button %}}

左侧

{{% button href="https://gohugo.io/" icon="download" %}}Get Hugo{{% /button %}}
Get Hugo

右侧

{{% button href="https://gohugo.io/" icon="download" iconposition="right" %}}Get Hugo{{% /button %}}
Get Hugo

重载严重性样式

{{% button href="https://gohugo.io/" icon="dragon" style="warning" %}}Get Hugo{{% /button %}}
Get Hugo

目标

{{% button href="https://gohugo.io/" target="_self" %}}Get Hugo in same window{{% /button %}}
{{% button href="https://gohugo.io/" %}}Get Hugo in new Window/Frame (default){{% /button %}}
Get Hugo in same Window/Frame Get Hugo in new Window/Frame (default)

其他

具有用户定义的颜色、字体、图标和 Markdown 标题

{{% button href="https://gohugo.io/" color="fuchsia" icon="fab fa-hackerrank" %}}Get **Hugo**{{% /button %}}
Get Hugo

具有所有默认值的严重性样式

{{% button href="https://gohugo.io/" style="tip" %}}{{% /button %}}
提示

按钮到内部页面

{{% button href="/index.html" %}}Home{{% /button %}}
Home

Button with JavaScript Action

如果您的 JavaScript 操作之后没有更改焦点,请确保调用this.blur() 最后取消选择按钮。

{{% button style="primary" icon="bullhorn" href="javascript:alert('你好,世界!');this.blur();" %}}你好世界{{% /button %}}

form元素中的按钮

要在 Markdown 中使用原生 HTML 元素,请将其添加到 hugo.toml

[markup.goldmark.renderer]
    unsafe = true
<form action="../../search.html" method="get">
  <input name="search-by-detail" class="search-by" type="search">
  {{% button type="submit" style="secondary" icon="search" %}}搜索{{% /button %}}
</form>

1.3 子页(children)


子页(children)简码列出了当前页面的子页面及其后代页面。

用法

{{% children sort="weight" %}}

参数

名称默认描述
containerstyleulChoose the style used to group all children. It could be any HTML tag name.
styleliChoose the style used to display each descendant. It could be any HTML tag name.
showhiddenfalseWhen true, child pages hidden from the menu will be displayed as well.
descriptionfalseWhen true shows a short text under each page in the list. When no description or summary exists for the page, the first 70 words of the content is taken - read more info about summaries on gohugo.io.
depth1The depth of descendants to display. For example, if the value is 2, the shortcode will display two levels of child pages. To get all descendants, set this value to a high number eg. 999.
sortautoThe sort criteria of the displayed list.

- auto defaults to ordersectionsby of the pages frontmatter
    or to ordersectionsby of the site configuration
    or to weight
- weight
- title
- linktitle
- modifieddate
- expirydate
- publishdate
- date
- length
- default adhering to Hugo’s default sort criteria

案例

默认

{{% children  %}}

带描述

{{% children description="true" %}}

无限深度和隐藏页面

{{% children depth="999" showhidden="true" %}}

容器和元素的标题样式

{{% children containerstyle="div" style="h2" depth="3" description="true" %}}

子页 1

子页案例

子页 1-1

子页案例

子页 2

子页案例

Div: 组和元素样式

{{% children containerstyle="div" style="div" depth="3" %}}

子页(children) 的子部分

3.1 子页 1


这是子页案例!

子页 1 的子部分

1.1 子页 1-1


这是子页案例!

3.2 子页 2


这是子页案例!

1.4 扩展(expand)


expand简码显示可展开/可折叠的文本部分

Thank you!

That’s some text with a footnote1

That’s some more text with a footnote.2


  1. And that’s the footnote. ↩︎

  2. Anything of interest goes here.

    Blue light glows blue. ↩︎

注释

这只能在现代浏览器中完美运行。虽然 Internet Explorer 11 在显示它时存在问题,但该功能仍然有效。

用法

{{% expand title="Expand me..." %}}Thank you!{{% /expand %}}
{{% expand "Expand me..." %}}Thank you!{{% /expand %}}

参数

NamePositionDefaultNotes
title1"Expand me..."Arbitrary text to appear next to the expand/collapse icon.
open2falseWhen true the content text will be initially shown as expanded.
<content><empty>Arbitrary text to be displayed on expand.

案例

默认

{{% expand %}}Yes, you did it!{{% /expand %}}

Yes, you did it!

最初扩展

{{% expand title="Expand me..." open="true" %}}No need to press you!{{% /expand %}}

No need to press you!

任意文本

{{% expand title="Show me almost **endless** possibilities" %}}
You can add standard markdown syntax:

- multiple paragraphs
- bullet point lists
- _emphasized_, **bold** and even **_bold emphasized_** text
- [links](https://example.com)
- etc.

```plaintext
...and even source code
```

> the possibilities are endless (almost - including other shortcodes may or may not work)
{{% /expand %}}

You can add standard markdown syntax:

  • multiple paragraphs
  • bullet point lists
  • emphasized, bold and even bold emphasized text
  • links
  • etc.
...and even source code

the possibilities are endless (almost - including other shortcodes may or may not work)

1.5 高亮(highlight)


highlight 使用语法高亮显示来呈现您的代码。

1print("Hello World!")

用法

这个简码与 Hugohighlight 简码但提供了一些扩展。

它的调用方式与 Hugo 自己的短代码相同,提供位置参数或简单地使用 codefences。

您也可以自由地从自己的部分调用此短代码。在这种情况下,它类似于雨果的highlight功能语法,如果使用兼容性语法将此简码称为部分。

虽然示例使用带有命名参数的短代码,但建议改用 codefences。这是因为越来越多的其他软件支持共同防御(例如。GitHub),因此您的 Markdown 变得更加可移植。

```py { lineNos="true" wrap="true" title="python" }
print("Hello World!")
```
{{< highlight lineNos="true" type="py" wrap="true" title="python" >}}
print("Hello World!")
{{< /highlight >}}
{{< highlight py "lineNos=true,wrap=true,title=python" >}}
print("Hello World!")
{{< /highlight >}}

参数

名称位置默认Note注释s
type1<空>要突出显示的代码语言。从支持的语言之一中进行选择。不区分大小写。
title<空>扩展。 代码的任意标题。如果出现以下情况,则会像单个选项卡一样显示代码hl_inline=false(这是 Hugos 的默认设置)。
wrap扩展。 当内容可以换行时,否则它将是可滚动的。
默认值true,可以在hugo.toml并通过 frontmatter 覆盖。见下文
options2<空>此表中零个或多个 Hugo 支持的选项 以及扩展参数的可选逗号分隔列表。
<option><空>Hugo 支持的任何选项.
<content><空>需要语法高亮的代码.

配置

Hugo 支持选项 的默认值可以通过 goldmark 设置hugo.toml

扩展选项的默认值可以通过hugo.toml或被每个单独页面的 frontmatter 覆盖。

全局配置文件

您可以在颜色变体样式表文件中配置用于代码块的颜色样式。

推荐设置

[markup]
  [markup.highlight]
    lineNumbersInTable = false
    noClasses = false

可选设置

[params]
  highlightWrap = true

页面 Frontmatter

highlightWrap = true

案例

带起始偏移量的行号

如上所述,如果代码换行,布局中的行号将发生变化,因此最好使用table inline.为了让您更轻松,请将lineNumbersInTable = false在你的hugo.toml并添加lineNos = true调用简码而不是特定值时,或者table inline.

{{< highlight lineNos="true" lineNoStart="666" type="py" >}}
# the hardest part is to start writing code; here's a kickstart; just copy and paste this; it's free; the next lines will cost you serious credits
print("Hello")
print(" ")
print("World")
print("!")
{{< /highlight >}}
666# the hardest part is to start writing code; here's a kickstart; just copy and paste this; it's free; the next lines will cost you serious credits
667print("Hello")
668print(" ")
669print("World")
670print("!")

有标题的Codefence

```py { title="python" }
# a bit shorter
print("Hello World!")
```
# a bit shorter
print("Hello World!")

带装饰

{{< highlight type="py" wrap="true" hl_lines="2" >}}
# Quicksort Python One-liner
lambda L: [] if L==[] else qsort([x for x in L[1:] if x< L[0]]) + L[0:1] + qsort([x for x in L[1:] if x>=L[0]])
# Some more stuff
{{< /highlight >}}
# Quicksort Python One-liner
lambda L: [] if L==[] else qsort([x for x in L[1:] if x< L[0]]) + L[0:1] + qsort([x for x in L[1:] if x>=L[0]])
# Some more stuff

无装饰

{{< highlight type="py" wrap="false" hl_lines="2" >}}
# Quicksort Python One-liner
lambda L: [] if L==[] else qsort([x for x in L[1:] if x< L[0]]) + L[0:1] + qsort([x for x in L[1:] if x>=L[0]])
# Some more stuff
{{< /highlight >}}
# Quicksort Python One-liner
lambda L: [] if L==[] else qsort([x for x in L[1:] if x< L[0]]) + L[0:1] + qsort([x for x in L[1:] if x>=L[0]])
# Some more stuff

1.6 图标(icon)


icon简码使用 Font Awesome 库显示图标。

Usage

{{% icon icon="exclamation-triangle" %}}
{{% icon icon="angle-double-up" %}}
{{% icon icon="skull-crossbones" %}}
{{% icon exclamation-triangle %}}
{{% icon angle-double-up %}}
{{% icon skull-crossbones %}}

参数

名称位置默认注释
icon1要显示的Font Awesome icon name 。它将以其相应上下文的文本颜色显示。

查找图标

浏览 Font Awesome Gallery 中的可用图标。请注意,免费过滤器已启用,因为默认情况下只有免费图标可用。

进入特定图标的 Font Awesome 页面(例如心形heart页面)后,复制图标名称并粘贴到 Markdown 内容中。

自定义图标

Font Awesome提供了许多修改图标的方法

  • 更改颜色(默认情况下,图标将继承父颜色)
  • 增大或减小尺寸
  • 旋转
  • 与其他图标结合使用

查看有关使用 CSS 的 Web 字体 的完整文档,了解更多信息。

案例

标准用法

Built with {{% icon heart %}} by Relearn and Hugo

Built with by Relearn and Hugo

高级 HTML 用法

虽然简码简化了标准图标的使用,但 Font Awesome 库的图标自定义和其他高级功能要求您直接使用 HTML。将 <i> HTML 粘贴到标记中,Font Awesome 将加载相关图标。

Built with <i class="fas fa-heart"></i> by Relearn and Hugo

由 Relearn 和 Hugo 构建。

要在 Markdown 中使用这些原生 HTML 元素,请将其添加到hugo.toml:

[markup.goldmark.renderer]
    unsafe = true

1.7 包含文件(include)


include简码在当前页面中包含项目中的其他文件。

用法

{{% include file="include_me.md" %}}
{{% include "include_me.md" %}}

包含的文件甚至可以包含 Markdown,并且在生成目录时会被考虑在内。

参数

名称位置默认注释
file1<empty>要包含的文件的路径。路径分辨率遵循Hugo的内置readFile功能
hidefirstheading2falsetrue:当包含的文件包含标题时,第一个标题将被隐藏。例如,这派上用场。如果包含其他独立的 Markdown 文件。

案例

任意内容

{{% include "4_tools/1_theme/include_me.md" %}}

文件包含案例

1.8 数学公式(math)


math简码使用 MathJax 库生成漂亮的格式化数学和化学公式。

$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
注释

这仅适用于现代浏览器。

用法

虽然示例使用带有命名参数的短代码,但建议改用 codefences。这是因为越来越多的其他软件支持数学协同防御(例如。GitHub),因此您的 Markdown 变得更加可移植。

```math { align="center" }
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
```
{{< math align="center" >}}
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
{{< /math >}}

参数

名称默认注释
aligncenter允许值 left, center or right.
<content><empty>公式内容.

配置

MathJax 配置了默认设置。您可以通过 JSON 对象自定义 MathJax 对所有文件的默认设置hugo.toml或通过您的页面 frontmatter 覆盖每个页面的这些设置。

你的 JSON 对象hugo.toml/ frontmatter 被转发到 MathJax 的配置对象中。

有关所有允许的设置,请参阅 MathJax 文档

全局配置文件

[params]
  mathJaxInitialize = "{ \"chtml\": { \"displayAlign\": \"left\" } }"

页面 Frontmatter

mathJaxInitialize = "{ \"chtml\": { \"displayAlign\": \"left\" } }"

案例

内联数学公式

如果果使用单个`$`作为公式周围的分隔符,则会生成内联数学: {{< math >}}$\sqrt{3}${{< /math >}}

如果果使用单个$作为公式周围的分隔符,则会生成内联数学: $\sqrt{3}$

右对齐的块级数学

如果将公式分隔为两个连续的`$$`公式,则会生成一个新块。

{{< math align="right" >}}
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
{{< /math >}}

如果将公式分隔为两个连续的$$公式,则会生成一个新块。

$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

Codefence

```math
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
```
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

化学式

{{< math >}}
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
{{< /math >}}
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$

1.9 流图(mermaid)


The mermaid shortcode generates diagrams and flowcharts from text, in a similar manner as Markdown using the Mermaid library.

graph LR;
    If --> Then
    Then --> Else
注释

这仅适用于现代浏览器。

用法

While the examples are using shortcodes with named parameter it is recommended to use codefences instead. This is because more and more other software supports Mermaid codefences (eg. GitHub) and so your markdown becomes more portable.

You are free to also call this shortcode from your own partials.

```mermaid { align="center" zoom="true" }
graph LR;
    If --> Then
    Then --> Else
```
{{< mermaid align="center" zoom="true" >}}
graph LR;
    If --> Then
    Then --> Else
{{< /mermaid >}}

The generated graphs can be be panned by dragging them and zoomed by using the mousewheel. On mobile devices you can use finger gestures.

参数

名称默认注释
aligncenterAllowed values are left, center or right.
zoomsee notesWhether the graph is pan- and zoomable.

If not set the value is determined by the mermaidZoom setting of the site or the pages frontmatter or false if not set at all.

- false: no pan or zoom
- true: pan and zoom active
<content><empty>Your Mermaid graph.

配置

Mermaid is configured with default settings. You can customize Mermaid’s default settings for all of your files thru a JSON object in your hugo.toml, override these settings per page thru your pages frontmatter or override these setting per diagramm thru diagram directives.

The JSON object of your hugo.toml / frontmatter is forwarded into Mermaid’s mermaid.initialize() function.

See Mermaid documentation for all allowed settings.

The theme setting can also be set by your used color variant. This will be the sitewide default and can - again - be overridden by your settings in hugo.toml, frontmatter or diagram directives.

全局配置文件

[params]
  mermaidInitialize = "{ \"theme\": \"dark\" }"
  mermaidZoom = true

页面 Frontmatter

mermaidInitialize = "{ \"theme\": \"dark\" }"
mermaidZoom = true

案例

带 YAML 样式标题的 流程图

{{< mermaid >}}
---
title: Example Diagram
---
graph LR;
    A[Hard edge] -->|Link text| B(Round edge)
    B --> C{<strong>Decision</strong>}
    C -->|One| D[Result one]
    C -->|Two| E[Result two]
{{< /mermaid >}}
---
title: Example Diagram
---
graph LR;
    A[Hard edge] -->|Link text| B(Round edge)
    B --> C{<strong>Decision</strong>}
    C -->|One| D[Result one]
    C -->|Two| E[Result two]

带配置指令的序列图

{{< mermaid >}}
%%{init:{"fontFamily":"monospace", "sequence":{"showSequenceNumbers":true}}}%%
sequenceDiagram
    Alice->>John: Hello John, how are you?
    loop Healthcheck
        John->>John: Fight against hypochondria
    end
    Note right of John: Rational thoughts!
    John-->>Alice: Great!
    John->>Bob: How about you?
    Bob-->>John: Jolly good!
{{< /mermaid >}}
%%{init:{"fontFamily":"monospace", "sequence":{"showSequenceNumbers":true}}}%%
sequenceDiagram
    Alice->>John: Hello John, how are you?
    loop Healthcheck
        John->>John: Fight against hypochondria
    end
    Note right of John: Rational thoughts!
    John-->>Alice: Great!
    John->>Bob: How about you?
    Bob-->>John: Jolly good!

具有Codefence语法的类图

```mermaid
classDiagram
    Animal <|-- Duck
    Animal <|-- Fish
    Animal <|-- Zebra
    Animal : +int age
    Animal : +String gender
    Animal: +isMammal()
    Animal: +mate()
    class Duck{
      +String beakColor
      +swim()
      +quack()
    }
    class Fish{
      -int sizeInFeet
      -canEat()
    }
    class Zebra{
      +bool is_wild
      +run()
    }
```
classDiagram
    Animal <|-- Duck
    Animal <|-- Fish
    Animal <|-- Zebra
    Animal : +int age
    Animal : +String gender
    Animal: +isMammal()
    Animal: +mate()
    class Duck{
      +String beakColor
      +swim()
      +quack()
    }
    class Fish{
      -int sizeInFeet
      -canEat()
    }
    class Zebra{
      +bool is_wild
      +run()
    }

向右对齐的状态图

{{< mermaid align="right" >}}
stateDiagram-v2
    open: Open Door
    closed: Closed Door
    locked: Locked Door
    open   --> closed: Close
    closed --> locked: Lock
    locked --> closed: Unlock
    closed --> open: Open
{{< /mermaid >}}
stateDiagram-v2
  open: Open Door
  closed: Closed Door
  locked: Locked Door
  open   --> closed: Close
  closed --> locked: Lock
  locked --> closed: Unlock
  closed --> open: Open

非默认主题的实体关系模型

{{< mermaid >}}
%%{init:{"theme":"forest"}}%%
erDiagram
    CUSTOMER }|..|{ DELIVERY-ADDRESS : has
    CUSTOMER ||--o{ ORDER : places
    CUSTOMER ||--o{ INVOICE : "liable for"
    DELIVERY-ADDRESS ||--o{ ORDER : receives
    INVOICE ||--|{ ORDER : covers
    ORDER ||--|{ ORDER-ITEM : includes
    PRODUCT-CATEGORY ||--|{ PRODUCT : contains
    PRODUCT ||--o{ ORDER-ITEM : "ordered in"
{{< /mermaid >}}
%%{init:{"theme":"forest"}}%%
erDiagram
    CUSTOMER }|..|{ DELIVERY-ADDRESS : has
    CUSTOMER ||--o{ ORDER : places
    CUSTOMER ||--o{ INVOICE : "liable for"
    DELIVERY-ADDRESS ||--o{ ORDER : receives
    INVOICE ||--|{ ORDER : covers
    ORDER ||--|{ ORDER-ITEM : includes
    PRODUCT-CATEGORY ||--|{ PRODUCT : contains
    PRODUCT ||--o{ ORDER-ITEM : "ordered in"

用户旅程

{{< mermaid >}}
journey
    title My working day
    section Go to work
      Make tea: 5: Me
      Go upstairs: 3: Me
      Do work: 1: Me, Cat
    section Go home
      Go downstairs: 5: Me
      Sit down: 3: Me
{{< /mermaid >}}
journey
    title My working day
    section Go to work
      Make tea: 5: Me
      Go upstairs: 3: Me
      Do work: 1: Me, Cat
    section Go home
      Go downstairs: 5: Me
      Sit down: 3: Me

甘特图

{{< mermaid >}}
gantt
        dateFormat  YYYY-MM-DD
        title Adding GANTT diagram functionality to Mermaid
        section A section
        Completed task            :done,    des1, 2014-01-06,2014-01-08
        Active task               :active,  des2, 2014-01-09, 3d
        Future task               :         des3, after des2, 5d
        Future task2              :         des4, after des3, 5d
        section Critical tasks
        Completed task in the critical line :crit, done, 2014-01-06,24h
        Implement parser and jison          :crit, done, after des1, 2d
        Create tests for parser             :crit, active, 3d
        Future task in critical line        :crit, 5d
        Create tests for renderer           :2d
        Add to Mermaid                      :1d
{{< /mermaid >}}
gantt
        dateFormat  YYYY-MM-DD
        title Adding GANTT diagram functionality to Mermaid
        section A section
        Completed task            :done,    des1, 2014-01-06,2014-01-08
        Active task               :active,  des2, 2014-01-09, 3d
        Future task               :         des3, after des2, 5d
        Future task2              :         des4, after des3, 5d
        section Critical tasks
        Completed task in the critical line :crit, done, 2014-01-06,24h
        Implement parser and jison          :crit, done, after des1, 2d
        Create tests for parser             :crit, active, 3d
        Future task in critical line        :crit, 5d
        Create tests for renderer           :2d
        Add to Mermaid                      :1d

不带缩放的饼图

{{< mermaid zoom="false" >}}
pie title Pets adopted by volunteers
    "Dogs" : 386
    "Cats" : 85
    "Rats" : 15
{{< /mermaid >}}
pie title Pets adopted by volunteers
    "Dogs" : 386
    "Cats" : 85
    "Rats" : 15

象限图

{{< mermaid >}}
pie title Pets adopted by volunteers
    title Reach and engagement of campaigns
    x-axis Low Reach --> High Reach
    y-axis Low Engagement --> High Engagement
    quadrant-1 We should expand
    quadrant-2 Need to promote
    quadrant-3 Re-evaluate
    quadrant-4 May be improved
    Campaign A: [0.3, 0.6]
    Campaign B: [0.45, 0.23]
    Campaign C: [0.57, 0.69]
    Campaign D: [0.78, 0.34]
    Campaign E: [0.40, 0.34]
    Campaign F: [0.35, 0.78]
{{< /mermaid >}}
quadrantChart
    title Reach and engagement of campaigns
    x-axis Low Reach --> High Reach
    y-axis Low Engagement --> High Engagement
    quadrant-1 We should expand
    quadrant-2 Need to promote
    quadrant-3 Re-evaluate
    quadrant-4 May be improved
    Campaign A: [0.3, 0.6]
    Campaign B: [0.45, 0.23]
    Campaign C: [0.57, 0.69]
    Campaign D: [0.78, 0.34]
    Campaign E: [0.40, 0.34]
    Campaign F: [0.35, 0.78]

需求图

{{< mermaid >}}
    requirementDiagram

    requirement test_req {
    id: 1
    text: the test text.
    risk: high
    verifymethod: test
    }

    element test_entity {
    type: simulation
    }

    test_entity - satisfies -> test_req
{{< /mermaid >}}
    requirementDiagram

    requirement test_req {
    id: 1
    text: the test text.
    risk: high
    verifymethod: test
    }

    element test_entity {
    type: simulation
    }

    test_entity - satisfies -> test_req

Git 图

{{< mermaid >}}
gitGraph
    commit
    commit
    branch develop
    checkout develop
    commit
    commit
    checkout main
    merge develop
    commit
    commit
{{< /mermaid >}}
gitGraph
    commit
    commit
    branch develop
    checkout develop
    commit
    commit
    checkout main
    merge develop
    commit
    commit

C4 图

{{< mermaid >}}
C4Context
    title System Context diagram for Internet Banking System
    Enterprise_Boundary(b0, "BankBoundary0") {
    Person(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")
    Person(customerB, "Banking Customer B")
    Person_Ext(customerC, "Banking Customer C", "desc")

    Person(customerD, "Banking Customer D", "A customer of the bank, <br/> with personal bank accounts.")

    System(SystemAA, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments.")

    Enterprise_Boundary(b1, "BankBoundary") {

        SystemDb_Ext(SystemE, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.")

        System_Boundary(b2, "BankBoundary2") {
        System(SystemA, "Banking System A")
        System(SystemB, "Banking System B", "A system of the bank, with personal bank accounts. next line.")
        }

        System_Ext(SystemC, "E-mail system", "The internal Microsoft Exchange e-mail system.")
        SystemDb(SystemD, "Banking System D Database", "A system of the bank, with personal bank accounts.")

        Boundary(b3, "BankBoundary3", "boundary") {
        SystemQueue(SystemF, "Banking System F Queue", "A system of the bank.")
        SystemQueue_Ext(SystemG, "Banking System G Queue", "A system of the bank, with personal bank accounts.")
        }
    }
    }

    BiRel(customerA, SystemAA, "Uses")
    BiRel(SystemAA, SystemE, "Uses")
    Rel(SystemAA, SystemC, "Sends e-mails", "SMTP")
    Rel(SystemC, customerA, "Sends e-mails to")

    UpdateElementStyle(customerA, $fontColor="red", $bgColor="grey", $borderColor="red")
    UpdateRelStyle(customerA, SystemAA, $textColor="blue", $lineColor="blue", $offsetX="5")
    UpdateRelStyle(SystemAA, SystemE, $textColor="blue", $lineColor="blue", $offsetY="-10")
    UpdateRelStyle(SystemAA, SystemC, $textColor="blue", $lineColor="blue", $offsetY="-40", $offsetX="-50")
    UpdateRelStyle(SystemC, customerA, $textColor="red", $lineColor="red", $offsetX="-50", $offsetY="20")

    UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="1")
{{< /mermaid >}}
C4Context
    title System Context diagram for Internet Banking System
    Enterprise_Boundary(b0, "BankBoundary0") {
    Person(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")
    Person(customerB, "Banking Customer B")
    Person_Ext(customerC, "Banking Customer C", "desc")

    Person(customerD, "Banking Customer D", "A customer of the bank, <br/> with personal bank accounts.")

    System(SystemAA, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments.")

    Enterprise_Boundary(b1, "BankBoundary") {

        SystemDb_Ext(SystemE, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.")

        System_Boundary(b2, "BankBoundary2") {
        System(SystemA, "Banking System A")
        System(SystemB, "Banking System B", "A system of the bank, with personal bank accounts. next line.")
        }

        System_Ext(SystemC, "E-mail system", "The internal Microsoft Exchange e-mail system.")
        SystemDb(SystemD, "Banking System D Database", "A system of the bank, with personal bank accounts.")

        Boundary(b3, "BankBoundary3", "boundary") {
        SystemQueue(SystemF, "Banking System F Queue", "A system of the bank.")
        SystemQueue_Ext(SystemG, "Banking System G Queue", "A system of the bank, with personal bank accounts.")
        }
    }
    }

    BiRel(customerA, SystemAA, "Uses")
    BiRel(SystemAA, SystemE, "Uses")
    Rel(SystemAA, SystemC, "Sends e-mails", "SMTP")
    Rel(SystemC, customerA, "Sends e-mails to")

    UpdateElementStyle(customerA, $fontColor="red", $bgColor="grey", $borderColor="red")
    UpdateRelStyle(customerA, SystemAA, $textColor="blue", $lineColor="blue", $offsetX="5")
    UpdateRelStyle(SystemAA, SystemE, $textColor="blue", $lineColor="blue", $offsetY="-10")
    UpdateRelStyle(SystemAA, SystemC, $textColor="blue", $lineColor="blue", $offsetY="-40", $offsetX="-50")
    UpdateRelStyle(SystemC, customerA, $textColor="red", $lineColor="red", $offsetX="-50", $offsetY="20")

    UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="1")

思维导图

{{< mermaid >}}
mindmap
  root((mindmap))
    Origins
      Long history
      ::icon(fa fa-book)
      Popularisation
        British popular psychology author Tony Buzan
    Research
      On effectiveness<br/>and features
      On Automatic creation
        Uses
            Creative techniques
            Strategic planning
            Argument mapping
    Tools
      Pen and paper
      Mermaid
{{< /mermaid >}}
mindmap
  root((mindmap))
    Origins
      Long history
      ::icon(fa fa-book)
      Popularisation
        British popular psychology author Tony Buzan
    Research
      On effectiveness<br/>and features
      On Automatic creation
        Uses
            Creative techniques
            Strategic planning
            Argument mapping
    Tools
      Pen and paper
      Mermaid

时间线

{{< mermaid >}}
timeline
    title History of Social Media Platform
    2002 : LinkedIn
    2004 : Facebook
         : Google
    2005 : Youtube
    2006 : Twitter
{{< /mermaid >}}
timeline
    title History of Social Media Platform
    2002 : LinkedIn
    2004 : Facebook
         : Google
    2005 : Youtube
    2006 : Twitter

桑基

{{< mermaid >}}
sankey-beta

%% source,target,value
Electricity grid,Over generation / exports,104.453
Electricity grid,Heating and cooling - homes,113.726
Electricity grid,H2 conversion,27.14
{{< /mermaid >}}
sankey-beta

%% source,target,value
Electricity grid,Over generation / exports,104.453
Electricity grid,Heating and cooling - homes,113.726
Electricity grid,H2 conversion,27.14

XYChart

{{< mermaid >}}
xychart-beta
    title "Sales Revenue"
    x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
    y-axis "Revenue (in $)" 4000 --> 11000
    bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
    line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
{{< /mermaid >}}
xychart-beta
    title "Sales Revenue"
    x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
    y-axis "Revenue (in $)" 4000 --> 11000
    bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
    line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]

块图

{{< mermaid >}}
block-beta
columns 1
  db(("DB"))
  blockArrowId6<["&nbsp;&nbsp;&nbsp;"]>(down)
  block:ID
    A
    B["A wide one in the middle"]
    C
  end
  space
  D
  ID --> D
  C --> D
  style B fill:#969,stroke:#333,stroke-width:4px
{{< /mermaid >}}
block-beta
columns 1
  db(("DB"))
  blockArrowId6<["&nbsp;&nbsp;&nbsp;"]>(down)
  block:ID
    A
    B["A wide one in the middle"]
    C
  end
  space
  D
  ID --> D
  C --> D
  style B fill:#969,stroke:#333,stroke-width:4px

1.10 注解(Notice)


notice 简码显示各种类型的免责声明,并带有可调节的颜色、标题和图标,以帮助您构建页面。

There may be pirates

这一切都与盒子有关。

用法

{{% notice style="primary" title="There may be pirates" icon="skull-crossbones" %}}
It is all about the boxes.
{{% /notice %}}
{{% notice primary "There may be pirates" "skull-crossbones" %}}
It is all about the boxes.
{{% /notice %}}

参数

名称位置默认注释
style1default框使用的样式方案。

- 严重程度: info, note, tip, warning
- 印记颜色:primary, secondary, accent
- 颜色: blue, green, grey, orange, red
- 特殊颜色: default, transparent, code
colorsee notes要使用的 CSS 颜色值。如果未设置,则选择的颜色取决于样式。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的漂亮颜色
- 对于所有其他样式:相应的颜色
title2see notes框的标题的任意文本。根据样式的不同,可能会有一个默认标题。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的标题
- 对于所有其他样式:<空>

如果您不希望严重性样式的标题,则必须将此参数设置为" "(一个充满空格的非空字符串)。
icon3see notesFont Awesome icon name 设置在标题的左侧。根据样式的不同,可能会有一个默认图标。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的漂亮图标
- 对于所有其他样式:<空>

如果您不想为严重性样式使用图标,则必须将此参数设置为" "(填充空格的非空字符串)
<content><empty>要在框中显示的任意文本。

案例

按严重性

带有标记的信息

{{% notice style="info" %}}
An **information** disclaimer

You can add standard markdown syntax:

- multiple paragraphs
- bullet point lists
- _emphasized_, **bold** and even ***bold emphasized*** text
- [links](https://example.com)
- etc.

```plaintext
...and even source code
```

> the possibilities are endless (almost - including other shortcodes may or may not work)
{{% /notice %}}
信息

An information disclaimer

You can add standard markdown syntax:

  • multiple paragraphs
  • bullet point lists
  • emphasized, bold and even bold emphasized text
  • links
  • etc.
...and even source code

the possibilities are endless (almost - including other shortcodes may or may not work)

Note

{{% notice style="note" %}}
A **notice** disclaimer
{{% /notice %}}
注释

A notice disclaimer

Tip

{{% notice style="tip" %}}
A **tip** disclaimer
{{% /notice %}}
提示

A tip disclaimer

Warning

{{% notice style="warning" %}}
A **warning** disclaimer
{{% /notice %}}
警告

A warning disclaimer

带有非默认标题和图标的 Warning

{{% notice style="warning" title="Here are dragons" icon="dragon" %}}
A **warning** disclaimer
{{% /notice %}}
Here are dragons

A warning disclaimer

没有标题和图标的 Warning

{{% notice style="warning" title=" " icon=" " %}}
A **warning** disclaimer
{{% /notice %}}

A warning disclaimer

按品牌颜色

仅具有标题 Primary

{{% notice style="primary" title="Primary" %}}
A **primary** disclaimer
{{% /notice %}}
Primary

A primary disclaimer

仅具有图标的 Secondary

{{% notice style="secondary" icon="stopwatch" %}}
A **secondary** disclaimer
{{% /notice %}}

A secondary disclaimer

Accent

{{% notice style="accent" %}}
An **accent** disclaimer
{{% /notice %}}

An accent disclaimer

按颜色

没有标题和图标的 Blue

{{% notice style="blue" %}}
A **blue** disclaimer
{{% /notice %}}

A blue disclaimer

仅带标题的 Green

{{% notice style="green" title="Green" %}}
A **green** disclaimer
{{% /notice %}}
Green

A green disclaimer

仅带图标的 Grey

{{% notice style="grey" icon="bug" %}}
A **grey** disclaimer
{{% /notice %}}

A grey disclaimer

带有标题和图标的 Orange

{{% notice style="orange" title="Orange" icon="bug" %}}
A **orange** disclaimer
{{% /notice %}}
Orange

A orange disclaimer

没有标题和图标的 Red

{{% notice style="red" %}}
A **red** disclaimer
{{% /notice %}}

A red disclaimer

按特殊颜色

使用位置参数的默认值

{{% notice default "Pay Attention to this Note!" "skull-crossbones" %}}
Some serious information.
{{% /notice %}}
Pay Attention to this Note!

Some serious information.

透明的标题和图标

{{% notice style="transparent" title="Pay Attention to this Note!" icon="skull-crossbones" %}}
Some serious information.
{{% /notice %}}
Pay Attention to this Note!

Some serious information.

具有用户定义的颜色、Font Awesome 字体的品牌图标和 Markdown 标题

{{% notice color="fuchsia" title="**Hugo**" icon="fab fa-hackerrank" %}}
Victor? Is it you?
{{% /notice %}}
Hugo

Victor? Is it you?

1.11 站点参数


siteparam 简码打印站点参数的值。

用法

{{% siteparam name="editURL" %}}
{{% siteparam "editURL" %}}

参数

NamePositionDefaultNotes
name1<empty>要显示的站点参数的名称。

案例

editURL from hugo.toml

`editURL` value: {{% siteparam name="editURL" %}}

editURL value: https://github.com/irscript/irscript.github.io/blob/main/content/${FilePath}

具有 Markdown 和 HTML 格式的嵌套参数

要使用 formatted 参数,请将其添加到 hugo.toml:

[markup.goldmark.renderer]
  unsafe = true

现在,包含 Markdown 的值将正确设置格式。

[params]
  [params.siteparam.test]
    text = "A **nested** parameter <b>with</b> formatting"
Formatted parameter: {{% siteparam name="siteparam.test.text" %}}

Formatted parameter:

1.12 标签页


tab简码来显示单个选项卡。

如果要使用显式语言标记代码示例,这将特别有用。

如果要将多个选项卡组合在一起,可以将选项卡包装到选项卡简码中。

printf("Hello World!");

用户

{{% tab title="c" %}}
```c
printf("Hello World!");
```
{{% /tab %}}

参数

名称默认注释
stylesee notes用于选项卡的样式方案。如果未设置样式,而是在选项卡内显示单个代码块,则其默认样式将适应块的样式。否则codedefault被使用。
- 按严重性:info,note,tip,warning
- 按品牌颜色:primary,secondary,accent
- 按颜色:blue,green,grey,orange
- 按特殊颜色:red,default,transparent,code
colorsee notes要使用的 CSS 颜色值。如果未设置,则选择的颜色取决于样式。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的漂亮颜色
- 对于所有其他样式:相应的颜色
titlesee notes标题的任意文本。根据样式的不同,可能会有一个默认标题。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的标题
- 对于所有其他样式:<空>

如果您不希望严重性样式的标题,则必须将此参数设置为" "(一个充满空格的非空字符串)。
iconsee notesFont Awesome icon name 设置在标题的左侧。根据样式的不同,可能会有一个默认图标。任何给定的值都将覆盖默认值。

- 对于严重性样式:严重性匹配的漂亮图标
- 对于所有其他样式:<空>

如果您不想为严重性样式使用图标,则必须将此参数设置为" "(填充空格的非空字符串)
<content><empty>任意文本,可以为 <空>

案例

具有折叠边距的单个代码块

{{% tab title="Code" %}}
```python
printf("Hello World!");
```
{{% /tab %}}
printf("Hello World!");

混合 Markdown 内容

{{% tab title="_**Mixed**_" %}}
选项卡不仅可以包含代码还可以包含任意文本在这种情况下文本和代码将获得边距
```python
printf("Hello World!");
```
{{% /tab %}}

选项卡不仅可以包含代码,还可以包含任意文本。在这种情况下,文本和代码将获得边距。

printf("Hello World!");

理解stylecolor 行为

style参数会影响参数color的应用方式

{{< tabs >}}
{{% tab title="just colored style" style="blue" %}}
The `style` parameter is set to a color style.

This will set the background to a lighter version of the chosen style color as configured in your theme variant.
{{% /tab %}}
{{% tab title="just color" color="blue" %}}
Only the `color` parameter is set.

This will set the background to a lighter version of the chosen CSS color value.
{{% /tab %}}
{{% tab title="default style and color" style="default" color="blue" %}}
The `style` parameter affects how the `color` parameter is applied.

The `default` style will set the background to your `--MAIN-BG-color` as configured for your theme variant resembling the default style but with different color.
{{% /tab %}}
{{% tab title="just severity style" style="info" %}}
The `style` parameter is set to a severity style.

This will set the background to a lighter version of the chosen style color as configured in your theme variant and also affects the chosen icon.
{{% /tab %}}
{{% tab title="severity style and color" style="info" color="blue" %}}
The `style` parameter affects how the `color` parameter is applied.

This will set the background to a lighter version of the chosen CSS color value and also affects the chosen icon.
{{% /tab %}}
{{< /tabs >}}

The style parameter is set to a color style.

This will set the background to a lighter version of the chosen style color as configured in your theme variant.

Only the color parameter is set.

This will set the background to a lighter version of the chosen CSS color value.

The style parameter affects how the color parameter is applied.

The default style will set the background to your --MAIN-BG-color as configured for your theme variant resembling the default style but with different color.

The style parameter is set to a severity style.

This will set the background to a lighter version of the chosen style color as configured in your theme variant and also affects the chosen icon.

The style parameter affects how the color parameter is applied.

This will set the background to a lighter version of the chosen CSS color value and also affects the chosen icon.

1.13 多标签页


tabs 简码在无限数量的选项卡中显示任意内容。

例如,这派上用场。用于提供多种语言的代码片段。

如果您只想要一个选项卡,则可以改为将选项卡称为独立选项卡简码。

hello.
print("Hello World!")
echo "Hello World!"
printf("Hello World!");

用法

有关嵌套选项卡参数的说明,请参阅tab选项卡简码。

{{< tabs title="hello." >}}
{{% tab title="py" %}}
```python
print("Hello World!")
```
{{% /tab %}}
{{% tab title="sh" %}}
```bash
echo "Hello World!"
```
{{% /tab %}}
{{% tab title="c" %}}
```c
printf"Hello World!");
```
{{% /tab %}}
{{< /tabs >}}
{{ partial "shortcodes/tabs.html" (dict
  "page"  .
  "title" "hello."
  "content" (slice
    (dict
      "title" "py"
      "content" ("```python\nprint(\"Hello World!\")\n```" | .RenderString)
    )
    (dict
      "title" "sh"
      "content" ("```bash\necho \"Hello World!\"\n```" | .RenderString)
    )
    (dict
      "title" "c"
      "content" ("```c\nprintf(\"Hello World!\");\n```" | .RenderString)
    )
  )
)}}

参数

名称默认注释
groupid<random>选项卡视图所属的组的任意名称。
具有相同 groupid 的选项卡视图会同步其所选选项卡。选项卡选择会根据groupid用于选项卡视图。如果在选项卡组中找不到所选选项卡,则改为选择第一个选项卡。
这种同步适用于整个网站!
style<empty>为每个包含的选项卡设置默认值。可以被每个选项卡覆盖。有关可能的值,请参阅选项卡简码。
color<empty>为每个包含的选项卡设置默认值。可以被每个选项卡覆盖。有关可能的值,请参阅选项卡简码。
title<empty>写在选项卡视图前面的任意标题。
icon<empty>Font Awesome icon name设置在标题的左侧
<content><empty>使用子简码定义的任意数量的tab选项卡

案例

groupid 的行为

查看在选择不同选项卡时选项卡视图会发生什么情况。

按下 A 组的选项卡可同步切换 A 组的所有选项卡视图(如果选项卡可用),则 B 组的选项卡保持不变。

{{< tabs groupid="a" >}}
{{% tab title="json" %}}
{{< highlight json "linenos=true" >}}
{ "Hello": "World" }
{{< /highlight >}}
{{% /tab %}}
{{% tab title="_**XML**_ stuff" %}}
```xml
<Hello>World</Hello>
```
{{% /tab %}}
{{% tab title="text" %}}
    Hello World
{{% /tab %}}
{{< /tabs >}}
{{< tabs groupid="a" >}}
{{% tab title="json" %}}
{{< highlight json "linenos=true" >}}
{ "Hello": "World" }
{{< /highlight >}}
{{% /tab %}}
{{% tab title="XML stuff" %}}
```xml
<Hello>World</Hello>
```
{{% /tab %}}
{{< /tabs >}}
{{< tabs groupid="b" >}}
{{% tab title="json" %}}
{{< highlight json "linenos=true" >}}
{ "Hello": "World" }
{{< /highlight >}}
{{% /tab %}}
{{% tab title="XML stuff" %}}
```xml
<Hello>World</Hello>
```
{{% /tab %}}
{{< /tabs >}}

A 组,选项卡视图 1

1{ "Hello": "World" }
<Hello>World</Hello>
Hello World

A 组,选项卡视图 2

1{ "Hello": "World" }
<Hello>World</Hello>

B组

1{ "Hello": "World" }
<Hello>World</Hello>

嵌套选项卡视图和颜色

如果要嵌套选项卡视图,则需要使用{{< tab >}}而不是{{% tab %}}。请注意,在这种情况下,无法将 markdown 放在父选项卡中。

您还可以为所有选项卡设置样式和颜色参数,并在选项卡级别覆盖它们。有关可能的值,请参阅tab选项卡简码。

{{< tabs groupid="main" style="primary" title="Rationale" icon="thumbtack" >}}
{{< tab title="Text" >}}
  Simple text is possible here...
  {{< tabs groupid="tabs-example-language" >}}
  {{% tab title="python" %}}
  Python is **super** easy.

  - most of the time.
  - if you don't want to output unicode
  {{% /tab %}}
  {{% tab title="bash" %}}
  Bash is for **hackers**.
  {{% /tab %}}
  {{< /tabs >}}
{{< /tab >}}

{{< tab title="Code" style="default" color="darkorchid" >}}
  ...but no markdown
  {{< tabs groupid="tabs-example-language" >}}
  {{% tab title="python" %}}
  ```python
  print("Hello World!")
  ```
  {{% /tab %}}
  {{% tab title="bash" %}}
  ```bash
  echo "Hello World!"
  ```
  {{% /tab %}}
  {{< /tabs >}}
{{< /tab >}}
{{< /tabs >}}
Rationale

Simple text is possible here...

Python is super easy.

  • most of the time.
  • if you don’t want to output unicode

Bash is for hackers.

...but no markdown

print("Hello World!")
echo "Hello World!"