Skip to content

Commit

Permalink
feat: Hide full path to file in Wikilinks by default (jackyzha0#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolageorgiev2000 authored Sep 12, 2022
1 parent 0d1670a commit ca84da5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions layouts/partials/textprocessing.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

0 comments on commit ca84da5

Please sign in to comment.