From e4cc625c33ecd2992dcf60f408417c3067b4fa2b Mon Sep 17 00:00:00 2001
From: Aiden Bai <aiden.bai05@gmail.com>
Date: Tue, 03 May 2022 16:34:27 +0000
Subject: [PATCH] Add future note about init function

---
 layouts/partials/backlinks.html |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/layouts/partials/backlinks.html b/layouts/partials/backlinks.html
index 16b96cd..e42351a 100644
--- a/layouts/partials/backlinks.html
+++ b/layouts/partials/backlinks.html
@@ -2,20 +2,24 @@
 <ul class="backlinks">
     {{$url := urls.Parse .Site.BaseURL }}
     {{$host := strings.TrimRight "/" $url.Path }}
-    {{$curPage := strings.TrimPrefix $host (strings.TrimRight "/" .Page.RelPermalink) }}
-    {{$inbound := index $.Site.Data.linkIndex.index.backlinks $curPage}}
+    {{$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}}
-    {{- range $inbound -}}
-        {{$src := index . "source"}}
-        {{$src = replace $src " " "-"}}
-
-        <li>
-            <a href="{{$src | safeHTML}}">{{index . "source"}}</a>
-        </li>
+    {{$cleanedInbound := apply (apply $inbound "index" "." "source") "replace" "." " " "-"}}
+    {{- range $cleanedInbound | uniq -}}
+      {{$l := printf "%s%s/" $host .}}
+      {{$l = cond (eq $l "//") "/" $l}}
+      {{with (index $contentTable .)}}
+      <li>
+          <a href="{{$l}}">{{index (index . "title")}}</a>
+      </li>
+      {{end}}
     {{- end -}}
     {{else}}
     <li>
         No backlinks found
     </li>
     {{end}}
-</ul>
\ No newline at end of file
+</ul>

--
Gitblit v1.10.0