Initial commit
This commit is contained in:
22
themes/default/layouts/_default/_markup/render-link.html
Normal file
22
themes/default/layouts/_default/_markup/render-link.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{{- $isExternal := strings.HasPrefix .Destination "http" -}}
|
||||
{{- $parsed := urls.Parse .Destination -}}
|
||||
{{- $host := $parsed.Host -}}
|
||||
{{- $path := $parsed.Path -}}
|
||||
{{- $query := $parsed.RawQuery -}}
|
||||
{{- $aff := index site.Data.affiliates.sites $host -}}
|
||||
{{- $isAffiliated := false -}}
|
||||
{{- $newURL := .Destination -}}
|
||||
{{- if and $isExternal $aff -}}
|
||||
{{- $param := $aff.param -}}
|
||||
{{- $value := $aff.value -}}
|
||||
{{- $isAffiliated = true -}}
|
||||
{{- if $query }}
|
||||
{{- $newURL = printf "%s://%s%s?%s&%s=%s" $parsed.Scheme $host $path $query $param $value -}}
|
||||
{{- else }}
|
||||
{{- $newURL = printf "%s://%s%s?%s=%s" $parsed.Scheme $host $path $param $value -}}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
<a href="{{ $newURL }}" title="{{ .Title }}"
|
||||
{{- if $isExternal -}} rel="noreferrer" class="external-link{{ if $isAffiliated }} affiliated{{ end }}{{ if $isExternal }} external{{ end }}" {{- end -}}>
|
||||
{{- .Text | safeHTML -}}
|
||||
</a>
|
||||
Reference in New Issue
Block a user