{{ $text_link := .Text }}
{{ if strings.HasPrefix .Destination "bib:" }}
    {{ $destination := (substr .Destination 4) }}
    {{ if index $.Page.Site.Data.books.piratecarecollection $destination }}
        {{ $b := index $.Page.Site.Data.books.piratecarecollection $destination }}
        {{ if not $text_link }}
            <span>{{ delimit $b.authors ", " " & " }}{{ with $b.pubdate }}, {{ substr . 0 4}}{{ end }}.<a href="/library/BROWSE_LIBRARY.html#/book/{{ $destination }}"{{ with $b.title}} title="{{ . }}"{{ end }} target="_blank"><i>‘{{ $b.title }}’</i></a>. {{ with $b.publisher }}{{ . }}.{{ end }}</span>
        {{ else }}
            <a href="/library/BROWSE_LIBRARY.html#/book/{{ $destination }}"{{ with $b.title}} title="{{ . }}"{{ end }} target="_blank">{{ $text_link }}</a>
        {{ end }}
    {{ else }}
            <a href="/library/BROWSE_LIBRARY.html#/book/{{ $destination }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ $text_link }}⦚<span class="text-xs font-bold p-1 bg-AuChico text-CoconutCream">bib:{{ $destination }} not found</span></a>
    {{ end }}
{{ else if strings.HasPrefix .Destination "session:" }}
    {{ $s_destination := printf "/session/%s" (substr .Destination 8) }}
    {{ if $.Page.Site.GetPage $s_destination }}
        {{ $session := $.Page.Site.GetPage $s_destination }}
        {{ if not $text_link }}
            <a href="{{ $s_destination }}/{{ if eq hugo.Environment "offline" }}index.html{{ end }}"{{ with $session.Title}} title="{{ $session.Title }}"{{ end }}>{{ $session.Title }}</a>
        {{ else }}
            <a href="{{ $s_destination }}/{{ if eq hugo.Environment "offline" }}index.html{{ end }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ $text_link }}</a>
        {{ end }}
    {{ else }}
            <a href="{{ $s_destination }}/{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ $text_link }}⦚<span class="text-xs font-bold p-1 bg-AuChico text-CoconutCream">session:{{ $s_destination }} not found</span></a>
    {{ end }}
{{ else if strings.HasPrefix .Destination "topic:" }}
    {{ $t_destination := printf "/topic/%s" (substr .Destination 6) }}
    {{ if $.Page.Site.GetPage $t_destination }}
        {{ $topic := $.Page.Site.GetPage $t_destination }}
        {{ if not $text_link }}
            <a href="{{ $t_destination }}/{{ if eq hugo.Environment "offline" }}index.html{{ end }}"{{ with $topic.Title}} title="{{ $topic.Title }}"{{ end }}>{{ $topic.Title }}</a>
        {{ else }}
            <a href="{{ $t_destination }}/{{ if eq hugo.Environment "offline" }}index.html{{ end }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ $text_link }}</a>
        {{ end }}
    {{ else }}
            <a href="{{ $t_destination }}/{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ $text_link }}⦚<span class="text-xs font-bold p-1 bg-AuChico text-CoconutCream">topic:{{ $t_destination }} not found</span></a>
    {{ end }}
{{ else if findRE "^.*static" .Destination }}
  <img src="{{ (replaceRE "^.*static" "" .Destination ) | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
{{ else }}
  <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
{{ end }}