mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
20 lines
No EOL
1.1 KiB
HTML
20 lines
No EOL
1.1 KiB
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" $page.File.Path }}
|
|
{{- end }}
|
|
{{- $url := .url }}
|
|
{{- if strings.HasPrefix $url "HAHAHUGOSHORTCODE" }}
|
|
{{- warnf "%q: WARNING you must call the ref / relref shortcode with '%% %%' instead of '< >' to work correctly for the anchor target attribute" $page.File.Path }}
|
|
{{- end }}
|
|
{{- $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> |