Raw
 1{{- $currentPage := .PageInner | default .Page -}}
 2{{- $text := .Text -}}
 3{{- $destination := .Destination -}}
 4{{- $reference := dict "kind" "media" "destination" $destination -}}
 5{{- if strings.HasPrefix $destination "img:" -}}
 6  {{- $img_params := (substr $destination 4) -}}
 7  {{- $img_src := index (split $img_params " ") 0 -}}
 8  {{- $img_attr := strings.TrimPrefix $img_src $img_params -}}
 9  <img class="sandpoints-img" src="{{ partial "media-href.html" (dict "destination" $img_src "page" $currentPage) | safeURL }}" {{ $img_attr | safeHTMLAttr }} />
10{{- else if strings.HasPrefix $destination "vid:" -}}
11  {{- $vid_params := (substr $destination 4) -}}
12  {{- $vid_src := index (split $vid_params " ") 0 -}}
13  {{- $vid_attr := strings.TrimPrefix $vid_src $vid_params -}}
14  <video class="sandpoints-vid" controls src="{{ partial "media-href.html" (dict "destination" $vid_src "page" $currentPage) | safeURL }}" {{ $vid_attr | safeHTMLAttr }}></video>
15{{- else if strings.HasPrefix $destination "bib:" -}}
16  {{- $bib := substr $destination 4 -}}
17  {{- $b := index hugo.Data.books.catalog $bib -}}
18  {{- $reference = dict "kind" "bibs" "destination" $destination "id" $bib "title" ($b.title | default $text) -}}
19  {{- $library := printf "%sBROWSE_LIBRARY.html" (site.Params.sandpoints.catalogPrefix | default "/library/") | relURL -}}
20  {{- if $b -}}
21    {{- if not $text -}}
22      <span>{{- delimit $b.authors ", " " & " -}}{{- with $b.pubdate -}},&nbsp;{{- substr . 0 4 -}}{{- end -}}.&nbsp;<a href="{{ $library }}#/book/{{- $bib -}}"{{- with $b.title }} title="{{ . }}"{{ end -}}><span class="supt">bib⁄</span><i>{{- $b.title -}}</i></a>.&nbsp;{{- with $b.publisher -}}{{- . -}}.{{- end -}}</span>
23    {{- else -}}
24      <span class="supt">bib⁄</span><a href="{{ $library }}#/book/{{- $bib -}}"{{- with $b.title }} title="{{ . }}"{{ end -}}>{{- $text -}}</a>
25    {{- end -}}
26  {{- else -}}
27    {{- warnf "In %s bib:%s not found." (partial "page-source.html" $currentPage) $bib -}}
28    <span class="supt">bib⁄</span>{{- $text -}}
29  {{- end -}}
30{{- else if strings.HasPrefix $destination "audio:" -}}
31  {{- $a_destination := substr $destination 6 -}}
32  {{- if findRE "^.*static" $a_destination -}}
33    <span class="soundcite" data-url="{{- partial "media-href.html" (dict "destination" (replaceRE "^.*static" "" $a_destination) "page" $currentPage) | safeURL -}}">{{ $text }}</span>
34  {{- else -}}
35    <span class="soundcite" data-url="{{- partial "media-href.html" (dict "destination" $a_destination "page" $currentPage) | safeURL -}}">{{ $text }}</span>
36  {{- end -}}
37{{- else -}}
38  {{- $u := urls.Parse $destination -}}
39  {{- if not $u.Scheme -}}
40    {{- $page := site.GetPage $destination -}}
41    {{- if $page -}}
42      {{- $reference = dict "kind" "internal" "destination" $destination "path" $page.Path -}}
43      {{- if not $text -}}
44        {{- $text = $page.LinkTitle | htmlEscape -}}
45      {{- end -}}
46      {{- partial "page-link.html" (dict "page" $page "text" $text "label" $page.Section) -}}
47    {{- else if findRE "^.*static" $destination -}}
48      <img src="{{- partial "media-href.html" (dict "destination" (replaceRE "^.*static" "" $destination) "page" $currentPage) | safeURL -}}" alt="{{- $text | plainify -}}"{{- with .Title }} title="{{ . }}"{{ end -}} />
49    {{- else -}}
50      <img src="{{- partial "media-href.html" (dict "destination" $destination "page" $currentPage) | safeURL -}}" alt="{{- $text | plainify -}}"{{- with .Title }} title="{{ . }}"{{ end -}} />
51    {{- end -}}
52  {{- else -}}
53    <img src="{{- partial "media-href.html" (dict "destination" $destination "page" $currentPage) | safeURL -}}" alt="{{- $text | plainify -}}"{{- with .Title }} title="{{ . }}"{{ end -}} />
54  {{- end -}}
55{{- end -}}
56{{- partial "content-reference.html" $reference -}}