Files
docker-docs/layouts/_default/_markup/render-link.html
Craig Osterhout 3a609cdfa3 fix mailto links (#22715)
<!--Delete sections as needed -->

## Description

Fix mailto links to work with the following syntax:

`[email me](mailto:example@example.com)`

Can verify at
https://deploy-preview-22715--docsdocker.netlify.app/desktop/enterprise/

## Related issues or tickets

https://docker.slack.com/archives/C039ZM6GH4Z/p1748022452990369

## Reviews

<!-- Notes for reviewers here -->
<!-- List applicable reviews (optionally @tag reviewers) -->

- [ ] Editorial review

Signed-off-by: Craig <craig.osterhout@docker.com>
2025-05-29 07:23:20 -07:00

23 lines
871 B
HTML

{{ $url := .Destination }}
{{- if (strings.HasPrefix $url "http") -}}
{{/* external link, add icon */}}
<a class="link" href="{{ $url | safeURL }}" rel="noopener">
{{ .Text | safeHTML }}
<span class="pl-1 icon-svg icon-sm">
{{ partialCached "icon" "open_in_new" "open_in_new" }}
</span>
</a>
{{- else if (strings.HasPrefix $url "mailto:") -}}
{{/* mailto link, render as normal link */}}
<a class="link" href="{{ $url }}">{{ .Text | safeHTML }}</a>
{{- else if (strings.HasPrefix $url "/") -}}
{{ if (strings.HasSuffix (urls.Parse $url).Path ".md") }}
{{/* abs path to markdown file, use ref */}}
{{ $url = (ref page $url) }}
{{ end }}
<a class="link" href="{{ $url }}">{{ .Text | safeHTML }}</a>
{{- else -}}
{{/* relative link, use ref */}}
<a class="link" href="{{ ref page $url }}">{{ .Text | safeHTML }}</a>
{{- end -}}