Add an external link marker to external links
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
13
layouts/_default/_markup/render-link.html
Normal file
13
layouts/_default/_markup/render-link.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{{- $absoluteDest := absLangURL .Destination -}}
|
||||
{{- $siteRootUrl := absLangURL "" -}}
|
||||
{{- $isExternal := not (hasPrefix $absoluteDest $siteRootUrl) -}}
|
||||
<a href="{{ .Destination | safeURL }}"
|
||||
{{- with .Title }} title="{{ . }}"{{ end -}}
|
||||
{{- if $isExternal -}}
|
||||
class="external-link" target="_blank" rel="noopener noreferrer"
|
||||
{{- end -}}
|
||||
>
|
||||
{{- with .Text | safeHTML }}{{ . }}{{ end -}}
|
||||
{{- if $isExternal -}}{{- partial "icon.html" "external-link" -}}{{- end -}}
|
||||
</a>
|
||||
{{- /* chomp trailing newline */ -}}
|
||||
Reference in New Issue
Block a user