From 256d00729293d3103d410c28a05008a079eb05db Mon Sep 17 00:00:00 2001
From: Nikola Georgiev <42315052+nikolageorgiev2000@users.noreply.github.com>
Date: Sat, 10 Sep 2022 19:46:49 +0100
Subject: [PATCH] Internal linking - displayed name fix
Internal links would display the subfolder name on my site. I added a line to split the title by "/" and keep the last element, i.e. the name name.
---
layouts/partials/textprocessing.html | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html
index 1cb2583dc..7891ea2f3 100644
--- a/layouts/partials/textprocessing.html
+++ b/layouts/partials/textprocessing.html
@@ -31,14 +31,22 @@
{{$img := printf "
" $path (default "auto" $width)}}
{{$content = replace $content . $img}}
{{else}}
+
{{$inner := . | strings.TrimPrefix "[[" | strings.TrimSuffix "]]" }}
+
{{$split := split $inner "|"}}
+
{{$path := index $split 0}}
{{$reference := split $path "#"}}
+
{{$title := index $reference 0}}
+
+ {{$title := index (last 1 (split $title "/")) 0}}
+
{{$block := default "" (index $reference 1)}}
{{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block)) | urlize | lower}}
{{$href := strings.TrimRight "/" ($page.GetPage $title).RelPermalink}}
+
{{$display := default $title (index $split 1)}}
{{if not $href}}
{{$link := printf "%s" $display}}