advise browser not to set referrerer for external links and open them in new tab
This commit is contained in:
18
layouts/_default/_markup/render-link.html
Normal file
18
layouts/_default/_markup/render-link.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{{- $parsedTitle := dict -}}
|
||||
{{- with .Title -}}
|
||||
{{- $parsedTitle = partial "functions/parse-title-attribute.html" . -}}
|
||||
{{- end -}}
|
||||
{{- $baseurl := urls.Parse .Page.Site.BaseURL -}}
|
||||
{{- $desturl := urls.Parse .Destination -}}
|
||||
|
||||
<a href="{{ .Destination | safeURL }}"
|
||||
{{- with $parsedTitle.title }} title="{{ . }}"{{- end -}}
|
||||
{{- with $parsedTitle.attributes -}}
|
||||
{{- range $k, $v := . -}}
|
||||
{{- printf " %s=%q" $k $v | safeHTMLAttr -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if and (strings.HasPrefix .Destination "http") (not (strings.HasPrefix $desturl.Host $baseurl.Host)) }} target="_blank" rel="external noreferrer noopener"{{ end -}}
|
||||
>{{ .Text | safeHTML }}</a>
|
||||
|
||||
{{- /* Strip trailing space. Code by djibe, thanks to jmooring & killbus */ -}}
|
||||
Reference in New Issue
Block a user