Make button shortcode use portable links
This commit is contained in:
@@ -11,7 +11,7 @@ layout: landing
|
||||
|
||||
{{< badge style="info" title="Badge" value="Value" >}} {{< badge style="default" title="Badge" value="Value" >}}
|
||||
|
||||
{{<button relref="/docs/example">}}Button{{</button>}}
|
||||
{{<button href="/docs/example">}}Button{{</button>}}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ Buttons are styled links that can lead to local page or external link.
|
||||
{{</* button href="https://github.com/alex-shpak/hugo-book" */>}}Contribute{{</* /button */>}}
|
||||
```
|
||||
|
||||
{{<button relref="/">}}Get Home{{</button>}}
|
||||
{{<button href="/">}}Get Home{{</button>}}
|
||||
{{<button href="https://github.com/alex-shpak/hugo-book">}}Contribute{{</button>}}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
{{- $ref := "" }}
|
||||
{{- $target := "" -}}
|
||||
{{- with .Get "href" -}}
|
||||
{{- $ref = . -}}
|
||||
{{- $target = "_blank" -}}
|
||||
{{- end -}}
|
||||
{{- with .Get "relref" -}}
|
||||
{{- $ref = relref $ . -}}
|
||||
{{- end -}}
|
||||
<a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" rel="noopener" {{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
|
||||
{{ $href := partial "docs/links/portable-link" (dict "Page" .Page "Destination" (.Get "href")) -}}
|
||||
{{ $isRemote := (urls.Parse $href).Scheme}}
|
||||
<a {{ with $href }}href="{{ $href }}"{{ end }} {{ with $isRemote }}target="_blank" rel="noopener"{{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
|
||||
{{- .InnerDeindent -}}
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user