mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +00:00
17 lines
No EOL
894 B
HTML
17 lines
No EOL
894 B
HTML
{{- $page := .page }}
|
|
{{- if and (not $page) .context }}
|
|
{{- $page = .context }}
|
|
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'link' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
|
|
{{- end }}
|
|
{{- $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 $page.Site.Params "externallinktarget" }}
|
|
{{- $target = $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> |