mirror of
https://github.com/imfing/hextra.git
synced 2025-08-25 14:36:39 -04:00
feat(links): add an option for external link decoration (#780)
* chore: add icons * feat: add option to flag outbound links * chore: generate * docs: add configuration * chore: use with the example site * chore: use one icon with rotation
This commit is contained in:

committed by
GitHub

parent
f297d24189
commit
a19de798b6
@@ -10,7 +10,16 @@
|
||||
{{- $dest = (relURL (strings.TrimPrefix "/" $dest)) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- with . -}}
|
||||
<a href="{{ $dest | safeURL }}" {{ with .Title }}title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }}target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>
|
||||
{{- $isExternal := strings.HasPrefix .Destination "http" -}}
|
||||
<a href="{{ $dest | safeURL }}"
|
||||
{{- with .Title -}}title="{{ . }}"{{- end -}}
|
||||
{{- if $isExternal -}}target="_blank" rel="noopener"{{- end -}}
|
||||
>
|
||||
{{- .Text | safeHTML -}}
|
||||
{{- if and .Page.Site.Params.externalLinkDecoration $isExternal -}}
|
||||
{{- partial "utils/icon.html" (dict "name" "arrow-up-right" "attributes" `class="hx:inline hx:rtl:rotate-270 hx:align-baseline" height="1em"`) -}}
|
||||
{{- end -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
|
Reference in New Issue
Block a user