Merge branch 'notice-title-param' of git://github.com/david-mk-lawrence/hugo-theme-relearn into david-mk-lawrence-notice-title-param

This commit is contained in:
Sören Weber 2021-10-24 11:12:10 +02:00
commit eca7824fff
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 ## 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 %}}

View file

@ -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 }}