mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 09:43:06 +00:00
Merge branch 'TB1234-main'
This commit is contained in:
commit
6b8449b0dc
4 changed files with 27 additions and 2 deletions
|
@ -16,6 +16,8 @@ This document shows you what's new in the latest release. For a detailed list of
|
||||||
|
|
||||||
## 5.4.0
|
## 5.4.0
|
||||||
|
|
||||||
|
- **Change**: The [`button` shortcode]({{% relref "shortcodes/button" %}}) has a new parameter `target` to set the destination frame/window for the URL to open. If not given, it defaults to a new window/tab for external URLs or is not set at all for internal URLs. Previously even internal URLs where opened in a new window/tab.
|
||||||
|
|
||||||
- **New**: The [`math` shortcode]({{% relref "shortcodes/math" %}}) and [`mermaid` shortcode]({{% relref "shortcodes/mermaid" %}}) now support alignment parameter also if codefence syntax is used.
|
- **New**: The [`math` shortcode]({{% relref "shortcodes/math" %}}) and [`mermaid` shortcode]({{% relref "shortcodes/mermaid" %}}) now support alignment parameter also if codefence syntax is used.
|
||||||
|
|
||||||
- **New**: Translation for Finnish (Suomi).
|
- **New**: Translation for Finnish (Suomi).
|
||||||
|
|
|
@ -51,6 +51,7 @@ Once the button is clicked, it opens another browser tab for the given URL.
|
||||||
| **style** | `transparent` | The color scheme used to paint the button.<br><br>- by severity: `info`, `note`, `tip`, `warning`<br>- by brand color: `primary`, `secondary`<br>- by color: `blue`, `green`, `grey`, `orange`, `red`<br>- by special color: `default`, `transparent` |
|
| **style** | `transparent` | The color scheme used to paint the button.<br><br>- by severity: `info`, `note`, `tip`, `warning`<br>- by brand color: `primary`, `secondary`<br>- by color: `blue`, `green`, `grey`, `orange`, `red`<br>- by special color: `default`, `transparent` |
|
||||||
| **icon** | see notes | [Font Awesome icon name]({{%relref "cont/icons#finding-an-icon" %}}) set to the left of the title. Depending on the **style** there may be a default icon. Any given value will overwrite the default.<br><br>- for severity styles: a nice matching icon for the severity<br>- for all other colors: _<empty>_<br><br>If you want no icon for a severity style, you have to set this parameter to `" "` (a non empty string filled with spaces) |
|
| **icon** | see notes | [Font Awesome icon name]({{%relref "cont/icons#finding-an-icon" %}}) set to the left of the title. Depending on the **style** there may be a default icon. Any given value will overwrite the default.<br><br>- for severity styles: a nice matching icon for the severity<br>- for all other colors: _<empty>_<br><br>If you want no icon for a severity style, you have to set this parameter to `" "` (a non empty string filled with spaces) |
|
||||||
| **iconposition** | `left` | Places the icon to the `left` or `right` of the title. |
|
| **iconposition** | `left` | Places the icon to the `left` or `right` of the title. |
|
||||||
|
| **target** | see notes | The destination frame/window for the URL. This behaves similar to normal links. If the parameter is not given it defaults to:<br><br>- `_blank` for any address starting with `http://` or `https://`<br>- no specific value for all other links |
|
||||||
| _**<content>**_ | see notes | Arbitrary text for the button title. Depending on the **style** there may be a default title. Any given value will overwrite the default.<br><br>- for severity styles: the matching title for the severity<br>- for all other colors: _<empty>_<br><br>If you want no title for a severity style, you have to set this parameter to `" "` (a non empty string filled with spaces) |
|
| _**<content>**_ | see notes | Arbitrary text for the button title. Depending on the **style** there may be a default title. Any given value will overwrite the default.<br><br>- for severity styles: the matching title for the severity<br>- for all other colors: _<empty>_<br><br>If you want no title for a severity style, you have to set this parameter to `" "` (a non empty string filled with spaces) |
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
@ -134,6 +135,15 @@ Once the button is clicked, it opens another browser tab for the given URL.
|
||||||
|
|
||||||
{{% button href="https://gohugo.io/" icon="dragon" style="warning" %}}Get Hugo{{% /button %}}
|
{{% button href="https://gohugo.io/" icon="dragon" style="warning" %}}Get Hugo{{% /button %}}
|
||||||
|
|
||||||
|
### Target
|
||||||
|
|
||||||
|
````go
|
||||||
|
{{%/* 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 */%}}
|
||||||
|
````
|
||||||
|
{{% button href="https://gohugo.io/" target="_self" %}}Get Hugo in same Window/Frame{{% /button %}}
|
||||||
|
{{% button href="https://gohugo.io/" %}}Get Hugo in new Window/Frame (default){{% /button %}}
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
|
||||||
#### Severity Style with all Defaults
|
#### Severity Style with all Defaults
|
||||||
|
@ -143,3 +153,11 @@ Once the button is clicked, it opens another browser tab for the given URL.
|
||||||
````
|
````
|
||||||
|
|
||||||
{{% button href="https://gohugo.io/" style="tip" %}}{{% /button %}}
|
{{% button href="https://gohugo.io/" style="tip" %}}{{% /button %}}
|
||||||
|
|
||||||
|
#### Button to internal page
|
||||||
|
|
||||||
|
````go
|
||||||
|
{{%/* button href="/" %}}Home{{% /button */%}}
|
||||||
|
````
|
||||||
|
|
||||||
|
{{% button href="/" %}}Home{{% /button %}}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
{{- $context := .context }}
|
{{- $context := .context }}
|
||||||
{{- $content := .content }}
|
{{- $content := .content }}
|
||||||
{{- $href := .href }}
|
{{- $href := .href | default "" }}
|
||||||
{{- $style := .style | default "transparent" }}
|
{{- $style := .style | default "transparent" }}
|
||||||
|
{{- $target := .target | default "" }}
|
||||||
|
{{- if and (eq (len $target) 0) (or (strings.HasPrefix $href "http://") (strings.HasPrefix $href "https://") ) }}
|
||||||
|
{{- $target = "_blank" }}
|
||||||
|
{{- end }}
|
||||||
{{- $title := .title | default ($content) | default ($style | T) }}
|
{{- $title := .title | default ($content) | default ($style | T) }}
|
||||||
{{- $icon := .icon | default "" }}
|
{{- $icon := .icon | default "" }}
|
||||||
{{- if and (not $icon) (eq (len $icon) 0) }}
|
{{- if and (not $icon) (eq (len $icon) 0) }}
|
||||||
|
@ -17,7 +21,7 @@
|
||||||
{{- $iconposition := .iconposition | default "left" }}
|
{{- $iconposition := .iconposition | default "left" }}
|
||||||
{{- with $context }}
|
{{- with $context }}
|
||||||
<span class="btn cstyle {{ $style }}">
|
<span class="btn cstyle {{ $style }}">
|
||||||
<a{{ if $href }} href="{{ $href }}" target="_blank"{{ end }}>
|
<a{{ if $href }} href="{{ $href }}"{{ if gt (len $target) 0 }} target="{{ $target }}" rel="noopener"{{ end }}{{ end }}>
|
||||||
{{- if and $icon (eq $iconposition "left") }}
|
{{- if and $icon (eq $iconposition "left") }}
|
||||||
<i class="{{ $icon }}"></i>
|
<i class="{{ $icon }}"></i>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -7,4 +7,5 @@
|
||||||
"iconposition" ((.Get "iconposition") | default (.Get "icon-position"))
|
"iconposition" ((.Get "iconposition") | default (.Get "icon-position"))
|
||||||
"style" (.Get "style")
|
"style" (.Get "style")
|
||||||
"title" (.Get "title")
|
"title" (.Get "title")
|
||||||
|
"target" (.Get "target")
|
||||||
) }}
|
) }}
|
Loading…
Reference in a new issue