From 13a5a34faa33901b3fdcc555efc6a197f2afa5ba Mon Sep 17 00:00:00 2001 From: Tobias Bauer Date: Tue, 18 Oct 2022 16:23:41 +0200 Subject: [PATCH 1/3] Button: add option for target --- layouts/partials/shortcodes/button.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/layouts/partials/shortcodes/button.html b/layouts/partials/shortcodes/button.html index a536640d91..59d826df08 100644 --- a/layouts/partials/shortcodes/button.html +++ b/layouts/partials/shortcodes/button.html @@ -2,6 +2,7 @@ {{- $content := .content }} {{- $href := .href }} {{- $style := .style | default "transparent" }} +{{- $target := .target | default "_blank" }} {{- $title := .title | default ($content) | default ($style | T) }} {{- $icon := .icon | default "" }} {{- if and (not $icon) (eq (len $icon) 0) }} @@ -17,7 +18,7 @@ {{- $iconposition := .iconposition | default "left" }} {{- with $context }} - + {{- if and $icon (eq $iconposition "left") }} {{- end }} From c0f750dfaba78e529fbefd3b457c5b25c9613128 Mon Sep 17 00:00:00 2001 From: Tobias Bauer Date: Wed, 19 Oct 2022 18:03:38 +0200 Subject: [PATCH 2/3] Add Support for shortcodes --- layouts/shortcodes/button.html | 1 + 1 file changed, 1 insertion(+) diff --git a/layouts/shortcodes/button.html b/layouts/shortcodes/button.html index 20125fb500..b39e2c097e 100644 --- a/layouts/shortcodes/button.html +++ b/layouts/shortcodes/button.html @@ -7,4 +7,5 @@ "iconposition" ((.Get "iconposition") | default (.Get "icon-position")) "style" (.Get "style") "title" (.Get "title") + "target" (.Get "target") ) }} \ No newline at end of file From 206bb1b3c86d957b5c6f1f8afe0628224bfc0106 Mon Sep 17 00:00:00 2001 From: Tobias Bauer Date: Wed, 19 Oct 2022 18:03:45 +0200 Subject: [PATCH 3/3] Add documentation --- exampleSite/content/shortcodes/button.en.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/exampleSite/content/shortcodes/button.en.md b/exampleSite/content/shortcodes/button.en.md index 23d362812f..05e98e27fa 100644 --- a/exampleSite/content/shortcodes/button.en.md +++ b/exampleSite/content/shortcodes/button.en.md @@ -52,6 +52,7 @@ Once the button is clicked, it opens another browser tab for the given URL. | **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.

- for severity styles: a nice matching icon for the severity
- for all other colors: _<empty>_

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. | | _**<content>**_ | see notes | Arbitray text for the button title. Depending on the **style** there may be a default title. Any given value will overwrite the default.

- for severity styles: the matching title for the severity
- for all other colors: _<empty>_

If you want no title for a severity style, you have to set this parameter to `" "` (a non empty string filled with spaces) | +| **target** | _blank | The destination frame/window for the URL. | ## 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 %}} +### 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 #### Severity Style with all Defaults