Improve consistency of handling shrotcode attributes

This commit is contained in:
Alex Shpak
2025-10-12 13:27:05 +02:00
parent 6c9e2a1918
commit 836a8a82d6
15 changed files with 140 additions and 34 deletions
+13 -1
View File
@@ -1,6 +1,18 @@
{{- $href := partial "docs/links/portable-link" (dict "Page" .Page "Destination" (.Get "href")) -}}
{{- $isRemote := (urls.Parse $href).IsAbs -}}
<a {{ with $href }}href="{{ $href }}"{{ end }} {{ with $isRemote }}target="_blank" rel="noopener"{{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"set" (dict
"href" $href
"target" "_blank"
"rel" "noopener"
)
"merge" (dict
"class" "book-btn"
)
"delete" (cond $isRemote (slice) (slice "target" "rel"))
) -}}
<a {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{- .InnerDeindent -}}
</a>
{{- /* remove whitespaces */ -}}