davideisinger.com

My personal website
Log | Files | Refs | README

commit 9a0f0809621af1bf9d00131908d72bb1f46888cd
parent ede6467e97878fb3639c00104b578070b91bb567
Author: David Eisinger <[email protected]>
Date:   Fri,  2 Jun 2023 23:53:47 -0400

Add backlinks to journal + notes

Diffstat:
Mthemes/v2/layouts/journal/single.html | 1+
Mthemes/v2/layouts/notes/single.html | 1+
Athemes/v2/layouts/partials/backlinks.html | 27+++++++++++++++++++++++++++
3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/themes/v2/layouts/journal/single.html b/themes/v2/layouts/journal/single.html @@ -18,4 +18,5 @@ {{ .Content }} {{- partial "references.html" . -}} + {{- partial "backlinks.html" . -}} {{ end }} diff --git a/themes/v2/layouts/notes/single.html b/themes/v2/layouts/notes/single.html @@ -6,4 +6,5 @@ {{ .Content }} {{- partial "references.html" . -}} + {{- partial "backlinks.html" . -}} {{ end }} diff --git a/themes/v2/layouts/partials/backlinks.html b/themes/v2/layouts/partials/backlinks.html @@ -0,0 +1,27 @@ +{{ $currlink := .RelPermalink }} +{{ $noslash := substr .RelPermalink 0 -1 }} +{{ $backlinks := slice }} + +{{ range .Site.Pages }} + {{ $found := findRE $noslash .Content 1 }} + + {{ if and ($found) (ne $currlink .RelPermalink) }} + {{ $backlinks = $backlinks | append . }} + {{ end }} +{{ end }} + +{{ with $backlinks }} + <hr> + + <div class="references"> + <h3>Backlinks</h3> + + <ul> + {{ range . }} + <li> + <a href="{{ .RelPermalink }}">{{ .Title }}</a> + </li> + {{ end }} + </ul> + </div> +{{ end }}