{{ define "urls" }}

Backlinks, outgoing URLs, bibliographic references and internal links:

{{ $s := partialCached "scratch.html" . }}

{{ range $p := .Site.RegularPages }}
{{ with $p.File }}{{- substr .Dir 0 -1 -}}⁄{{ end }}{{ $p.Title }} {{ $pPath := printf "/%s" $p.File }} {{ with $ss := $s.Get $pPath }} {{ with $ss.backlinks }} {{ range $i, $_ := $ss.backlinks }} {{ if eq $i 0 }}
Mentioned in other Sandpoints pages ({{ len $ss.backlinks }}):
{{ end }} {{ end }} {{ with ($p.Scratch.Get "links") }} {{ range $i, $_ := uniq ($p.Scratch.Get "links") }} {{ if eq $i 0 }}
Internal links to other Sandpoint pages ({{ len (uniq ($p.Scratch.Get "links")) }}):
{{ end }} {{ $http_links := (slice) }} {{ $library_links := (slice) }} {{ $anchor_links := (slice) }} {{ $other_links := (slice) }} {{ with ($p.Scratch.Get "urls") }} {{- $c_prefix := $p.Site.Params.sandpointsCatalogPrefix | default "/library/" -}} {{ range $i, $_ := ($p.Scratch.Get "urls") }} {{ if strings.HasPrefix $_ "http" }} {{ $http_links = $http_links | append $_ }} {{ else if strings.HasPrefix $_ $c_prefix }} {{ $library_links = $library_links | append $_ }} {{ else}} {{ $other_links = $other_links | append $_ }} {{ end }} {{ end }} {{ end }} {{ with $http_links }} {{ range $i, $_ := $http_links }} {{ if eq $i 0 }}
Outgoing links to other pages on Internet ({{ len $http_links }}):
{{ end }} {{ with $library_links }} {{ range $i, $_ := $library_links }} {{ if eq $i 0 }}
Links to Sandpoint's library ({{ len $library_links }}):
{{ end }} {{ with ($p.Scratch.Get "bibs") }} {{ range $i, $_ := ($p.Scratch.Get "bibs") }} {{ if eq $i 0 }}
Bibliographic references ({{ len ($p.Scratch.Get "bibs") }}):
{{ end }} {{ with $other_links }} {{ $formattingN := 0 }} {{ $anchorN := 0 }} {{ range $i, $_ := $other_links }} {{ if eq $i 0 }}
Anchor, formatting and other links ({{ len $other_links }}):
{{ end }}
{{ end }} {{ end }}