blob: 4c5c0c03c05511e69c5ba4b79cd24154354fabe0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
{{- $destination := .Destination -}}
{{- $url := urls.Parse .Destination -}}
{{- $isRemote := gt (len $url.Host) 0 -}}
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
{{- if and (not $isRemote) (not $isFragment) -}}
{{- $path := strings.TrimPrefix "./" $url.Path -}}
{{- $path = strings.TrimSuffix ".md" $path -}}
{{- $path = strings.TrimSuffix "/_index" $path -}}
{{- with (.Page.GetPage $path) -}}
{{- $destination = .RelPermalink -}}
{{- else with (.Page.Resources.Get $path) -}}
{{- $destination = .RelPermalink -}}
{{- else with (resources.Get $path) -}}
{{- $destination = .RelPermalink -}}
{{- else -}}
{{- warnf "Reference '%s' not found in '%s'" .Destination .Page.Permalink -}}
{{- end -}}
{{- with $url.RawQuery -}}
{{- $destination = print $destination "?" . -}}
{{- end -}}
{{- with $url.Fragment -}}
{{- $destination = print $destination "#" . -}}
{{- end -}}
{{- end -}}
{{- return $destination -}}
|
; all rights regarding Text and Data Mining (TDM) are reserved.