Merge branch 'david-mk-lawrence-notice-title-param'

This commit is contained in:
Sören Weber 2021-10-24 11:13:28 +02:00
commit 20a73e3492
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
2 changed files with 20 additions and 2 deletions

View file

@ -8,11 +8,15 @@ The notice shortcode shows four types of disclaimers to help you structure your
## Usage
````go
{{%/* notice [ note | info | tip | warning ] */%}}
{{%/* notice [ note | info | tip | warning ] [?string] */%}}
Some markup
{{%/* /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
### Note
@ -190,3 +194,17 @@ You can add:
{{%/* /notice */%}}
````
{{% /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 %}}

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }}
{{- $style := .Get 0 }}
{{- $title := $style | T }}
{{- $title := .Get 1 | default ($style | T) }}
<div class="notices {{ $style }}">
<div class="label">{{ $title }}</div>
{{- .Inner }}