2025-04-18 12:05:39 +02:00
|
|
|
|
{{- $currentPage := .Page -}}
|
2025-04-20 00:01:16 +02:00
|
|
|
|
{{- $text := .Text -}}
|
|
|
|
|
{{- $destination := .Destination -}}
|
|
|
|
|
{{- $u := urls.Parse $destination -}}
|
2025-04-18 12:05:39 +02:00
|
|
|
|
{{- if not $u.Scheme -}}
|
2025-04-21 12:27:03 +02:00
|
|
|
|
{{- $page := site.GetPage $destination -}}
|
|
|
|
|
{{- if $page -}}
|
|
|
|
|
{{- $backlinks := $page.Store.Get "backlinks" | default slice -}}
|
2025-04-18 12:05:39 +02:00
|
|
|
|
{{- $backlinks := $backlinks|append $currentPage.RelPermalink -}}
|
2025-04-21 12:27:03 +02:00
|
|
|
|
{{- $page.Store.Set "backlinks" ($backlinks|uniq) -}}
|
2025-04-20 00:01:16 +02:00
|
|
|
|
{{- if not $text -}}
|
2025-04-21 12:27:03 +02:00
|
|
|
|
{{- $text = $page.LinkTitle -}}
|
2025-04-20 00:01:16 +02:00
|
|
|
|
{{- end -}}
|
2025-04-21 12:27:03 +02:00
|
|
|
|
<span class="supt">{{- $page.Section -}}⁄</span><a href="{{- $page.RelPermalink -}}" {{- with $page.Title }} title="{{ . }}"{{ end -}}>{{- $text -}}</a>
|
|
|
|
|
{{- else if hasPrefix $destination "/library/" -}}
|
2025-04-20 00:01:16 +02:00
|
|
|
|
{{- $bib := strings.TrimPrefix "/library/" $destination -}}
|
|
|
|
|
{{- $b := index site.Data.books.catalog $bib -}}
|
2025-04-21 12:27:03 +02:00
|
|
|
|
{{- if not $b.title -}}
|
2025-05-04 15:11:06 +02:00
|
|
|
|
{{- with $currentPage.File -}}
|
|
|
|
|
{{- warnf "In /%s bib:%s not found." .Path $bib -}}
|
|
|
|
|
{{- end -}}
|
2025-04-21 12:27:03 +02:00
|
|
|
|
{{- end -}}
|
2025-04-20 00:01:16 +02:00
|
|
|
|
{{- if not $text -}}
|
|
|
|
|
{{- $text = $b.title|default "" -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
<span class="supt">library⁄</span><a href="/library/BROWSE_LIBRARY.html#/books/{{- $bib -}}">{{- $text -}}</a>
|
2025-04-21 12:27:03 +02:00
|
|
|
|
{{- else -}}
|
2025-05-04 15:11:06 +02:00
|
|
|
|
{{- with $currentPage.File -}}
|
|
|
|
|
{{- warnf "In /%s broken link: %s" .Path $destination -}}
|
|
|
|
|
{{- end -}}
|
2025-04-20 00:01:16 +02:00
|
|
|
|
{{- end -}}
|
|
|
|
|
{{- else -}}
|
2025-05-04 15:11:06 +02:00
|
|
|
|
{{- if hasPrefix $destination "http" -}}
|
|
|
|
|
<span class="supt">www⁄</span>
|
|
|
|
|
{{- end -}}<a href="{{ $destination | safeURL }}"{{- with .Title }} title="{{ . }}"{{ end -}}{{- if $u.IsAbs }} rel="external"{{ end -}}>{{- if .Text }}{{ .Text }}{{- else -}}{{- $destination -}}{{- end -}}</a>
|
2025-04-18 12:05:39 +02:00
|
|
|
|
{{- end -}}
|
|
|
|
|
{{- /* chomp trailing newline */ -}}
|