mirror of https://github.com/docker/docs.git
31 lines
908 B
HTML
31 lines
908 B
HTML
{{ $url := .Destination }}
|
|
{{- if (strings.HasPrefix $url "http") -}}
|
|
{{/* external link, add icon */}}
|
|
<a
|
|
class="link"
|
|
href="{{ $url | safeURL }}"
|
|
target="_blank"
|
|
rel="noopener">
|
|
{{- .Text | safeHTML -}}
|
|
<span class="pl-1 icon-svg icon-sm">
|
|
{{- partial "icon" "open_in_new" -}}
|
|
</span></a>
|
|
{{- else if (strings.HasPrefix $url "/") -}}
|
|
{{/* absolute link, use url as-is */}}
|
|
<a class="link" href="{{ $url }}">{{ .Text | safeHTML }}</a>
|
|
{{- else -}}
|
|
{{/* check if the file links to index.md */}}
|
|
{{- if (strings.FindRE `([^_]|^)index.md` $url 1) -}}
|
|
<a
|
|
class="link"
|
|
href="{{ ref .Page (strings.Replace $url "index.md" "_index.md") }}"
|
|
>{{ .Text | safeHTML }}</a
|
|
>
|
|
{{- else -}}
|
|
{{/* relative link, use ref */}}
|
|
<a class="link" href="{{ ref .Page $url }}"
|
|
>{{ .Text | safeHTML }}</a
|
|
>
|
|
{{- end -}}
|
|
{{- end -}}
|