hugo-theme-relearn/layouts/partials/shortcodes/link.html

13 lines
644 B
HTML
Raw Normal View History

{{- $context := .context }}
{{- $url := .url }}
{{- $title := .title | default "" }}
{{- $title = trim $title " " }}
{{- $content := .content }}
{{- $target := .target | default "" }}
{{- if and (eq (len $target) 0) (or (strings.HasPrefix $url "http://") (strings.HasPrefix $url "https://") ) }}
{{- $target = "_blank" }}
{{- if isset $context.Page.Site.Params "externallinktarget" }}
{{- $target = $context.Page.Site.Params.externalLinkTarget }}
{{- end }}
{{- end -}}
<a href="{{ $url | safeURL }}"{{ if $title }} title="{{ $title }}"{{ end }}{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}>{{ $content | safeHTML }}</a>