From 6c2d102c910bcd2c94036dc1055911ef9d7d020b Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Sun, 14 Sep 2025 23:38:46 +0200 Subject: [PATCH] Make button shortcode use portable links --- exampleSite/content.en/_index.md | 2 +- exampleSite/content.en/docs/shortcodes/buttons.md | 2 +- layouts/_shortcodes/button.html | 13 +++---------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/exampleSite/content.en/_index.md b/exampleSite/content.en/_index.md index 723b24e..c9ff7ba 100644 --- a/exampleSite/content.en/_index.md +++ b/exampleSite/content.en/_index.md @@ -11,7 +11,7 @@ layout: landing {{< badge style="info" title="Badge" value="Value" >}} {{< badge style="default" title="Badge" value="Value" >}} -{{}} +{{}} diff --git a/exampleSite/content.en/docs/shortcodes/buttons.md b/exampleSite/content.en/docs/shortcodes/buttons.md index 15e3a3e..25f15b4 100644 --- a/exampleSite/content.en/docs/shortcodes/buttons.md +++ b/exampleSite/content.en/docs/shortcodes/buttons.md @@ -9,5 +9,5 @@ Buttons are styled links that can lead to local page or external link. {{}}Contribute{{}} ``` -{{}} +{{}} {{}} diff --git a/layouts/_shortcodes/button.html b/layouts/_shortcodes/button.html index efae3e0..cd7e016 100644 --- a/layouts/_shortcodes/button.html +++ b/layouts/_shortcodes/button.html @@ -1,12 +1,5 @@ -{{- $ref := "" }} -{{- $target := "" -}} -{{- with .Get "href" -}} - {{- $ref = . -}} - {{- $target = "_blank" -}} -{{- end -}} -{{- with .Get "relref" -}} - {{- $ref = relref $ . -}} -{{- end -}} - +{{ $href := partial "docs/links/portable-link" (dict "Page" .Page "Destination" (.Get "href")) -}} +{{ $isRemote := (urls.Parse $href).Scheme}} + {{- .InnerDeindent -}}