quartz-research-note/layouts/partials/backlinks.html

31 lines
1.1 KiB
HTML
Raw Normal View History

<h3>{{ i18n "backlinks" }}</h3>
<ul class="backlinks">
2021-08-12 13:29:35 +00:00
{{$url := urls.Parse .Site.BaseURL }}
{{$host := strings.TrimRight "/" $url.Path }}
{{$curPage := strings.TrimPrefix $host (strings.TrimRight "/" .Page.RelPermalink)}}
{{$linkIndex := getJSON "/assets/indices/linkIndex.json"}}
2022-02-16 00:39:14 +00:00
{{$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}}
2022-05-03 14:43:22 +00:00
{{$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}}
2021-07-18 13:35:42 +00:00
{{- end -}}
{{else}}
<li>
{{ i18n "no_backlinks" }}
</li>
{{end}}
</ul>