summaryrefslogtreecommitdiff
path: root/themes/hugo-book/layouts/_partials/docs/links/portable-image.html
blob: 4b9bc44ff9c5b8efd27ad4756a0e8f28ce71b628 (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
{{- $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.TrimPrefix "/assets/" $path -}}
  
  {{- with (.Page.Resources.Get $path) -}}
    {{- $destination = .RelPermalink -}}
  {{- else with (resources.Get $path) -}}
    {{- $destination = .RelPermalink -}}
  {{- else -}}
    {{- warnf "Image 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 -}}
Directive (EU) 2019/790, Article 4(3); all rights regarding Text and Data Mining (TDM) are reserved.