From 7b677a8a2eb155d6ce46ab99f1daa1dfe303e6c8 Mon Sep 17 00:00:00 2001 From: LM Date: Sun, 15 Oct 2023 00:37:03 +0200 Subject: [PATCH] better backlink computations --- .../partials/extensions/command-palette.html | 22 ++++++++++++++----- .../network/dynamic-backlink-multi-col.html | 19 +++++++++------- .../partials/network/dynamic-backlink.html | 21 ++++++++++-------- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/layouts/partials/extensions/command-palette.html b/layouts/partials/extensions/command-palette.html index aa59810..647fee4 100644 --- a/layouts/partials/extensions/command-palette.html +++ b/layouts/partials/extensions/command-palette.html @@ -59,14 +59,26 @@ {{ if .File }} {{ $fileReference := lower (replace .File "\\" "/") }} -{{ $urlPre := $.Site.BaseURL }} -{{ $dataNetwork := getJSON $urlPre "network.json" }} - {{ $sources := slice }} {{ $rawSources := slice }} +{{- range .Site.RegularPages -}} + {{ with .Params.links }} + {{ range . }} + {{ if eq . $fileReference }} + {{ $source := lower (replace . "\\" "/") }} + {{ with ($.Site.GetPage $source) }} + {{ if not (in $sources $source) }} + {{ $sources = $sources | append $source }} + {{ end }} + {{ end }} + {{ end }} + {{ end }} + {{ end }} +{{- end -}} -{{- range $dataNetwork.edges -}} + +{{/* {{- range $dataNetwork.edges -}} {{ if eq .target $fileReference }} {{ $source := lower (replace .source "\\" "/") }} {{ with ($.Site.GetPage $source) }} @@ -75,7 +87,7 @@ {{ end }} {{ end }} {{ end }} -{{- end -}} +{{- end -}} */}} {{- if $sources -}} {{ range $sources }} diff --git a/layouts/partials/network/dynamic-backlink-multi-col.html b/layouts/partials/network/dynamic-backlink-multi-col.html index 8190df0..5c54058 100644 --- a/layouts/partials/network/dynamic-backlink-multi-col.html +++ b/layouts/partials/network/dynamic-backlink-multi-col.html @@ -1,21 +1,24 @@ {{ $fileReference := lower (replace .File "\\" "/") }} {{ $urlPre := $.Site.BaseURL }} -{{ $dataNetwork := getJSON $urlPre "network.json" }} {{ $sources := slice }} {{ $rawSources := slice }} -{{ range $dataNetwork.edges }} - {{ if eq .target $fileReference }} - {{ $source := lower (replace .source "\\" "/") }} - {{ with ($.Site.GetPage $source) }} - {{ if not (in $sources $source) }} - {{ $sources = $sources | append $source }} +{{- range .Site.RegularPages -}} + {{ with .Params.links }} + {{ range . }} + {{ if eq . $fileReference }} + {{ $source := lower (replace . "\\" "/") }} + {{ with ($.Site.GetPage $source) }} + {{ if not (in $sources $source) }} + {{ $sources = $sources | append $source }} + {{ end }} + {{ end }} {{ end }} {{ end }} {{ end }} -{{ end}} +{{- end -}} {{ if $sources }} diff --git a/layouts/partials/network/dynamic-backlink.html b/layouts/partials/network/dynamic-backlink.html index f042469..34257aa 100644 --- a/layouts/partials/network/dynamic-backlink.html +++ b/layouts/partials/network/dynamic-backlink.html @@ -1,21 +1,24 @@ {{ $fileReference := lower (replace .File "\\" "/") }} {{ $urlPre := $.Site.BaseURL }} -{{ $dataNetwork := getJSON $urlPre "network.json" }} {{ $sources := slice }} {{ $rawSources := slice }} -{{ range $dataNetwork.edges }} - {{ if eq .target $fileReference }} - {{ $source := lower (replace .source "\\" "/") }} - {{ with ($.Site.GetPage $source) }} - {{ if not (in $sources $source) }} - {{ $sources = $sources | append $source }} +{{- range .Site.RegularPages -}} + {{ with .links }} + {{ range . }} + {{ if eq . $fileReference }} + {{ $source := lower (replace . "\\" "/") }} + {{ with ($.Site.GetPage $source) }} + {{ if not (in $sources $source) }} + {{ $sources = $sources | append $source }} + {{ end }} + {{ end }} {{ end }} {{ end }} {{ end }} -{{ end}} +{{- end -}} {{ if $sources }}
@@ -48,5 +51,5 @@ {{ else }}
No backlinks identified. Reference this note using the Note ID {{ $fileReference }} in other notes to connect them. -
+
{{ end }} \ No newline at end of file