From ca84da5b31fa00ca6c729a9b500efeb28f90b41b Mon Sep 17 00:00:00 2001
From: Nikola Georgiev <42315052+nikolageorgiev2000@users.noreply.github.com>
Date: Mon, 12 Sep 2022 00:05:14 +0000
Subject: [PATCH] feat: Hide full path to file in Wikilinks by default (#195)
---
layouts/partials/textprocessing.html | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html
index 1cb2583..7891ea2 100644
--- a/layouts/partials/textprocessing.html
+++ b/layouts/partials/textprocessing.html
@@ -31,14 +31,22 @@
{{$img := printf "<img src=\"%s\" width=\"%s\" />" $path (default "auto" $width)}}
{{$content = replace $content . $img}}
{{else}}
+ <!-- remove link delimiters -->
{{$inner := . | strings.TrimPrefix "[[" | strings.TrimSuffix "]]" }}
+ <!-- split from alias -->
{{$split := split $inner "|"}}
+ <!-- separate link path -->
{{$path := index $split 0}}
{{$reference := split $path "#"}}
+ <!-- path with heading link (i.e. $block) removed -->
{{$title := index $reference 0}}
+ <!-- ADDED LINE TO REMOVE SUBFOLDER FROM TITLE: -->
+ {{$title := index (last 1 (split $title "/")) 0}}
+ <!-- heading link -->
{{$block := default "" (index $reference 1)}}
{{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block)) | urlize | lower}}
{{$href := strings.TrimRight "/" ($page.GetPage $title).RelPermalink}}
+ <!-- if alias given, use alias, else title -->
{{$display := default $title (index $split 1)}}
{{if not $href}}
{{$link := printf "<a class=\"internal-link broken\">%s</a>" $display}}
--
Gitblit v1.10.0