mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +00:00
add support for optional parameter to use as title for notices
This commit is contained in:
parent
d1a935c299
commit
c239e76501
2 changed files with 20 additions and 2 deletions
|
@ -8,11 +8,15 @@ The notice shortcode shows four types of disclaimers to help you structure your
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
````go
|
````go
|
||||||
{{%/* notice [ note | info | tip | warning ] */%}}
|
{{%/* notice [ note | info | tip | warning ] [?string] */%}}
|
||||||
Some markup
|
Some markup
|
||||||
{{%/* /notice */%}}
|
{{%/* /notice */%}}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
The first parameter is required and indicates the type of notice.
|
||||||
|
|
||||||
|
The second parameter is optional. If provided, it will be used as the title of the notice. If not provided, then the type of notice will be used as the title. For example, the title of a warning notice will be "Warning".
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Note
|
### Note
|
||||||
|
@ -190,3 +194,17 @@ You can add:
|
||||||
{{%/* /notice */%}}
|
{{%/* /notice */%}}
|
||||||
````
|
````
|
||||||
{{% /expand %}}
|
{{% /expand %}}
|
||||||
|
|
||||||
|
### Notice with Custom Title
|
||||||
|
|
||||||
|
You can customize the title of the notice by passing it as a second parameter.
|
||||||
|
|
||||||
|
````go
|
||||||
|
{{%/* notice note "Pay Attention to this Note!" */%}}
|
||||||
|
The title is now the parameter that was provided.
|
||||||
|
{{%/* /notice */%}}
|
||||||
|
````
|
||||||
|
|
||||||
|
{{% notice note "Pay Attention to this Note!" %}}
|
||||||
|
The title is now the parameter that was provided.
|
||||||
|
{{% /notice %}}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{- $_hugo_config := `{ "version": 1 }` }}
|
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||||
{{- $style := .Get 0 }}
|
{{- $style := .Get 0 }}
|
||||||
{{- $title := $style | T }}
|
{{- $title := .Get 1 | default ($style | T) }}
|
||||||
<div class="notices {{ $style }}">
|
<div class="notices {{ $style }}">
|
||||||
<div class="label">{{ $title }}</div>
|
<div class="label">{{ $title }}</div>
|
||||||
{{- .Inner }}
|
{{- .Inner }}
|
||||||
|
|
Loading…
Reference in a new issue