mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 14:36:22 +00:00
30 lines
1.1 KiB
HTML
30 lines
1.1 KiB
HTML
<h3>Backlinks</h3>
|
|
<ul class="backlinks">
|
|
{{$url := urls.Parse .Site.BaseURL }}
|
|
{{$host := strings.TrimRight "/" $url.Path }}
|
|
{{$curPage := strings.TrimPrefix $host (strings.TrimRight "/" .Page.RelPermalink)}}
|
|
{{$linkIndex := getJSON "/assets/indices/linkIndex.json"}}
|
|
{{$inbound := index $linkIndex.index.backlinks $curPage}}
|
|
{{$contentTable := getJSON "/assets/indices/contentIndex.json"}}
|
|
{{if $inbound}}
|
|
{{$backlinks := dict "SENTINEL" "SENTINEL"}}
|
|
{{range $k, $v := $inbound}}
|
|
{{$cleanedInbound := replace $v.source " " "-"}}
|
|
{{$ctx := $v.text}}
|
|
{{$backlinks = merge $backlinks (dict $cleanedInbound $ctx)}}
|
|
{{end}}
|
|
{{- range $lnk, $ctx := $backlinks -}}
|
|
{{$l := printf "%s%s/" $host $lnk}}
|
|
{{$l = cond (eq $l "//") "/" $l}}
|
|
{{with (index $contentTable $lnk)}}
|
|
<li>
|
|
<a href="{{$l}}" data-ctx="{{$ctx}}" data-src="{{$lnk}}" class="internal-link">{{index (index . "title")}}</a>
|
|
</li>
|
|
{{end}}
|
|
{{- end -}}
|
|
{{else}}
|
|
<li>
|
|
No backlinks found
|
|
</li>
|
|
{{end}}
|
|
</ul>
|