{{- $text_link := .Text -}}
{{ $_ := newScratch }}
{{- range $k, $v := .Page.Site.Data.sandpointsnamegraph -}}
{{ $_.Add "triads" $k }}
{{- end -}}
{{- if strings.HasPrefix .Destination "img:" -}}
{{- $img_params := (substr .Destination 4) -}}
{{- $img_src := index (split $img_params " ") 0 -}}
{{- $img_attr := index (split $img_params $img_src) 1 -}}
{{- else if strings.HasPrefix .Destination "vid:" -}}
{{- $vid_params := (substr .Destination 4) -}}
{{- $vid_src := index (split $vid_params " ") 0 -}}
{{- $vid_attr := index (split $vid_params $vid_src) 1 -}}
{{- else if strings.HasPrefix .Destination "bib:" -}}
{{- $destination := (substr .Destination 4) -}}
{{- $c_prefix := .Page.Site.Params.sandpointsCatalogPrefix | default "/library/" -}}
{{- if index $.Page.Site.Data.books.catalog $destination -}}
{{- $b := index $.Page.Site.Data.books.catalog $destination -}}
{{- $bibhref := printf "%sBROWSE_LIBRARY.html#/book/%s" (safeURL ($c_prefix)) $destination }}
{{ $bibtitle := "" }}
{{ with $b.title }}
{{- $bibtitle = printf "%s" $b.title }}
{{ end }}
{{ .Page.Scratch.Add "bibs" (slice (slice $bibhref $bibtitle)) }}
{{- if not $text_link -}}
{{- delimit $b.authors ", " " & " -}}{{- with $b.pubdate -}}, {{- substr . 0 4}}{{- end -}}. bib⁄{{- $b.title -}}. {{- with $b.publisher -}}{{- . -}}.{{- end -}}
{{- else -}}
bib⁄{{- $text_link -}}
{{- end -}}
{{- else -}}
{{- $text_link -}}⦚bib:{{- $destination -}} not found
{{- end -}}
{{- else if in ($_.Get "triads") (index (split .Destination ":") 0) -}}
{{- if $.Page.Site.GetPage (printf "/%s" (replace .Destination ":" "/")) -}}
{{- $session := $.Page.Site.GetPage (printf "/%s" (replace .Destination ":" "/")) -}}
{{ .Page.Scratch.Add "links" (slice $session) }}
{{- if not $text_link -}}
{{- index (split .Destination ":") 0 -}}⁄{{- $session.Title -}}
{{- else -}}
{{- index (split .Destination ":") 0 -}}⁄{{- $text_link -}}
{{- end -}}
{{- else -}}
{{- $text_link -}}⦚{{- .Destination -}} not found
{{- end -}}
{{- else if strings.HasPrefix .Destination "audio:" -}}
{{- $a_destination := (substr .Destination 6) -}}
{{- if findRE "^.*static" $a_destination -}}
{{ .Text }}
{{- else -}}
{{ .Text }}
{{- end -}}
{{- else if findRE "^.*static" .Destination -}}
{{- else -}}
{{- end -}}