{{ define "main" }}

Backlinks, outgoing URLs, bibliographic references and internal links:

{{- with templates.Defer -}} {{- $graph := partialCached "graph.html" site site.Language.Lang -}} {{- $prefix := site.Params.sandpoints.catalogPrefix | default "/library/" -}} {{- range site.RegularPages -}} {{- $page := . -}} {{- $entry := index $graph.pages .Path -}} {{- $mentioned := slice -}} {{- range $label := slice "is in" "mentioned in" -}}{{- $mentioned = union $mentioned (index $entry.inverses $label | default slice) -}}{{- end -}} {{- range $label, $paths := $entry.inverses -}}{{- $mentioned = union $mentioned $paths -}}{{- end -}} {{- $mentioned = union $mentioned (index (partialCached "content-backlinks.html" site site.Language.Lang) .Path | default slice) -}} {{- $internal := slice -}} {{- range $entry.forward -}}{{- $internal = union $internal . -}}{{- end -}} {{- $external := slice -}}{{- $library := slice -}}{{- $other := slice -}}{{- $bibs := slice -}} {{- $anchors := 0 -}}{{- $formats := 0 -}} {{- range partialCached "page-references.html" . .Path .Language.Lang -}} {{- if eq .kind "internal" -}}{{- $internal = union $internal (slice .path) -}} {{- else if eq .kind "external" -}}{{- $external = $external | append .destination -}} {{- else if eq .kind "library" -}}{{- $library = $library | append .destination -}} {{- else if eq .kind "bibs" -}}{{- $bibs = $bibs | append . -}} {{- else if eq .kind "anchors" -}}{{- $anchors = add $anchors 1 -}} {{- else if eq .kind "formats" -}}{{- $formats = add $formats 1 -}} {{- else if eq .kind "other" -}}{{- $other = $other | append .destination -}}{{- end -}} {{- end -}}
{{ partial "page-link.html" (dict "page" . "label" .Section) }} {{- range slice (dict "name" "mentioned" "title" "Mentioned in other Sandpoints pages" "paths" $mentioned) (dict "name" "internal" "title" "Internal links to other Sandpoint pages" "paths" ($internal | uniq)) -}} {{- if .paths -}}
{{ .title }} ({{ len .paths }}):
{{- end -}} {{- end -}} {{- with $external -}}
Outgoing links to other pages on Internet ({{ len . }}):
{{- end -}} {{- with $library -}}
Links to Sandpoint's library ({{ len . }}):
{{- end -}} {{- with $bibs -}}
Bibliographic references ({{ len . }}):
{{- end -}} {{- $remaining := add (add $anchors $formats) (len $other) -}} {{- if $remaining -}}
Anchor, formatting and other links ({{ $remaining }}):
{{- end -}}
{{- end -}} {{- end -}} {{ end }}