Skip to content

Commit

Permalink
better backlink computations
Browse files Browse the repository at this point in the history
  • Loading branch information
emptymalei committed Oct 14, 2023
1 parent 2a871df commit 7b677a8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
22 changes: 17 additions & 5 deletions layouts/partials/extensions/command-palette.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand All @@ -75,7 +87,7 @@
{{ end }}
{{ end }}
{{ end }}
{{- end -}}
{{- end -}} */}}

{{- if $sources -}}
{{ range $sources }}
Expand Down
19 changes: 11 additions & 8 deletions layouts/partials/network/dynamic-backlink-multi-col.html
Original file line number Diff line number Diff line change
@@ -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 }}

Expand Down
21 changes: 12 additions & 9 deletions layouts/partials/network/dynamic-backlink.html
Original file line number Diff line number Diff line change
@@ -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 }}
<div class="box is-size-8">
Expand Down Expand Up @@ -48,5 +51,5 @@
{{ else }}
<div class="notification is-warning is-light is-size-8">
No backlinks identified. Reference this note using the Note ID <code>{{ $fileReference }}</code> in other notes to connect them.
</div>
</div>
{{ end }}

0 comments on commit 7b677a8

Please sign in to comment.