mirror of
https://github.com/McShelby/hugo-theme-relearn
synced 2025-05-09 04:07:50 +08:00
77 lines
1.4 KiB
Markdown
77 lines
1.4 KiB
Markdown
|
+++
|
||
|
description = "Show content in a single tab"
|
||
|
title = "Tab"
|
||
|
+++
|
||
|
|
||
|
You can use a `tab` shortcode to display a single tab.
|
||
|
|
||
|
This is especially useful if you want to flag your code example with an explicit language.
|
||
|
|
||
|
{{% tab name="c" %}}
|
||
|
|
||
|
```python
|
||
|
printf("Hello World!");
|
||
|
```
|
||
|
|
||
|
{{% /tab %}}
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
While the examples are using shortcodes with named parameter you are free to also call this shortcode from your own partials.
|
||
|
|
||
|
{{< tabs groupid="shortcode-parameter">}}
|
||
|
{{% tab name="shortcode" %}}
|
||
|
|
||
|
````go
|
||
|
{{%/* tab name="c" */%}}
|
||
|
```c
|
||
|
printf("Hello World!");
|
||
|
```
|
||
|
{{%/* /tab */%}}
|
||
|
````
|
||
|
|
||
|
{{% /tab %}}
|
||
|
{{% tab name="partial" %}}
|
||
|
|
||
|
````go
|
||
|
{{ partial "shortcodes/tab.html" (dict
|
||
|
"context" .
|
||
|
"name" "c"
|
||
|
"content" ("```c\nprintf(\"Hello World!\")\n```" | markdownify)
|
||
|
)}}
|
||
|
````
|
||
|
|
||
|
{{% /tab %}}
|
||
|
{{< /tabs >}}
|
||
|
|
||
|
### Parameter
|
||
|
|
||
|
| Name | Default | Notes |
|
||
|
|:----------------------|:---------------------|:------------|
|
||
|
| **name** | _<empty>_ | Arbitrary text for the name of the tab. |
|
||
|
| _**<content>**_ | _<empty>_ | Arbitrary text to be displayed in the tab. |
|
||
|
|
||
|
## Examples
|
||
|
|
||
|
### Code with collapsed margins
|
||
|
|
||
|
{{% tab name="Code" %}}
|
||
|
|
||
|
```python
|
||
|
printf("Hello World!");
|
||
|
```
|
||
|
|
||
|
{{% /tab %}}
|
||
|
|
||
|
### Mixed content
|
||
|
|
||
|
{{% tab name="Mixed" %}}
|
||
|
|
||
|
A tab can not only contain code but arbitrary text. In this case text and code will get a margin.
|
||
|
|
||
|
```python
|
||
|
printf("Hello World!");
|
||
|
```
|
||
|
|
||
|
{{% /tab %}}
|