From f63cc508b7ffc23be386af47c995bd6ddcf8395c Mon Sep 17 00:00:00 2001 From: Apoorv Khandelwal Date: Tue, 15 Nov 2022 18:43:08 -0500 Subject: [PATCH] Replacing "internal-link broken" with link to asset --- layouts/partials/textprocessing.html | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html index 6776fa5b1..3f6df5d49 100644 --- a/layouts/partials/textprocessing.html +++ b/layouts/partials/textprocessing.html @@ -35,23 +35,26 @@ {{$inner := . | strings.TrimPrefix "[[" | strings.TrimSuffix "]]" }} {{$split := split $inner "|"}} + {{$path := index $split 0}} {{$reference := split $path "#"}} {{$title := index $reference 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)}} - + {{$display := index (last 1 (split $display "/")) 0}} - {{if not $href}} - {{$link := printf "%s" $display}} + + {{if eq (string ($page.GetPage $title)) "nopPage"}} + {{$path := index $split 0 | relURL}} + {{$link := printf "%s" $path $display}} {{$content = replace $content . $link}} {{else}} + {{$block := default "" (index $reference 1)}} + {{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block)) | urlize | lower}} + {{$href := strings.TrimRight "/" ($page.GetPage $title).RelPermalink}} {{$fullhref := printf "%s%s" $href $block }} {{$link := printf "%s" $fullhref $href $display}} {{$content = replace $content . $link}}