|
- {{ define "urls" }}
- <h2>Backlinks, outgoing URLs, bibliographic references and internal links:</h2>
- {{ $s := partialCached "scratch.html" . }}
-
- <div id="toggleAllLinks" onclick="toggleAllLinks()">[toggle expand/collapse]</div>
- <p></p>
- {{ range $p := .Site.RegularPages }}
- <details><summary>{{ with $p.File }}<span class="sup">{{- substr .Dir 0 -1 -}}⁄</span>{{ end }}<a href="{{ $p.RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ $p.Title }}</a></summary>
-
- {{ $pPath := printf "/%s" $p.File }}
- {{ with $ss := $s.Get $pPath }}
- {{ with $ss.backlinks }}
- {{ range $i, $_ := $ss.backlinks }}
- {{ if eq $i 0 }}
- <details><summary>Mentioned in other Sandpoints pages ({{ len $ss.backlinks }}):</summary><ul>
- {{ end }}
- <li>{{ with $_.File }}<span class="sup">{{ substr .Dir 0 -1 }}⁄</span>{{ end }}<a href="{{ $_.RelPermalink }}">{{ $_.Title }}</a></li>
- {{ end }}
- </ul></details>
- {{ end }}
- {{ end }}
-
- {{ with ($p.Scratch.Get "links") }}
- {{ range $i, $_ := uniq ($p.Scratch.Get "links") }}
- {{ if eq $i 0 }}
- <details><summary>Internal links to other Sandpoint pages ({{ len (uniq ($p.Scratch.Get "links")) }}):</summary><ul>
- {{ end }}
- <li>{{ with $_.File }}<span class="sup">{{ substr .Dir 0 -1 }}⁄</span>{{ end }}<a href="{{ $_.RelPermalink }}">{{ $_.Title }}</a></li>
- {{ end }}
- </ul></details>
- {{ 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 }}
- <details><summary>Outgoing links to other pages on Internet ({{ len $http_links }}):</summary><ul>
- {{ end }}
- <li><span class="sup">www⁄</span><a href="{{ $_ }}" target="_blank">{{ $_ }}</a></li>
- {{ end }}
- </ul></details>
- {{ end }}
-
- {{ with $library_links }}
- {{ range $i, $_ := $library_links }}
- {{ if eq $i 0 }}
- <details><summary>Links to Sandpoint's library ({{ len $library_links }}):</summary><ul>
- {{ end }}
- <li><span class="sup">lib⁄</span><a href="{{ $_ }}" target="_blank">{{ $_ }}</a></li>
- {{ end }}
- </ul></details>
- {{ end }}
-
- {{ with ($p.Scratch.Get "bibs") }}
- {{ range $i, $_ := ($p.Scratch.Get "bibs") }}
- {{ if eq $i 0 }}
- <details><summary>Bibliographic references ({{ len ($p.Scratch.Get "bibs") }}):</summary><ul>
- {{ end }}
- <li><span class="sup">bib⁄</span><a href="{{ index $_ 0 }}" target="_blank">{{ index $_ 1 }}</a></li>
- {{ end }}
- </ul></details>
- {{ end }}
-
- {{ with $other_links }}
- {{ $formattingN := 0 }}
- {{ $anchorN := 0 }}
- {{ range $i, $_ := $other_links }}
- {{ if eq $i 0 }}
- <details><summary>Anchor, formatting and other links ({{ len $other_links }}):</summary><ul>
- {{ end }}
- {{ if strings.HasPrefix $_ "#" }}
- {{ $anchorN = add $anchorN 1 }}
- {{ else if strings.HasPrefix $_ "{"}}
- {{ $formattingN = add $formattingN 1 }}
- {{ else }}
- <li><span class="sup">other⁄</span><a href="{{ $_ }}" target="_blank">{{ $_ }}</a></li>
- {{ end }}
- {{ end }}
- {{ with $formattingN }}<li>{{ $formattingN }} formatting links.</a></li>{{ end }}
- {{ with $anchorN }}<li>{{ $anchorN }} anchor links.</a></li>{{ end }}
- </ul></details>
- {{ end }}
-
- </details>
-
- {{ end }}
- {{ end }}
|