mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 14:36:22 +00:00
feat: Hide full path to file in Wikilinks by default (#195)
This commit is contained in:
parent
0d1670adba
commit
ca84da5b31
1 changed files with 8 additions and 0 deletions
|
@ -31,14 +31,22 @@
|
||||||
{{$img := printf "<img src=\"%s\" width=\"%s\" />" $path (default "auto" $width)}}
|
{{$img := printf "<img src=\"%s\" width=\"%s\" />" $path (default "auto" $width)}}
|
||||||
{{$content = replace $content . $img}}
|
{{$content = replace $content . $img}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
<!-- remove link delimiters -->
|
||||||
{{$inner := . | strings.TrimPrefix "[[" | strings.TrimSuffix "]]" }}
|
{{$inner := . | strings.TrimPrefix "[[" | strings.TrimSuffix "]]" }}
|
||||||
|
<!-- split from alias -->
|
||||||
{{$split := split $inner "|"}}
|
{{$split := split $inner "|"}}
|
||||||
|
<!-- separate link path -->
|
||||||
{{$path := index $split 0}}
|
{{$path := index $split 0}}
|
||||||
{{$reference := split $path "#"}}
|
{{$reference := split $path "#"}}
|
||||||
|
<!-- path with heading link (i.e. $block) removed -->
|
||||||
{{$title := index $reference 0}}
|
{{$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 := default "" (index $reference 1)}}
|
||||||
{{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block)) | urlize | lower}}
|
{{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block)) | urlize | lower}}
|
||||||
{{$href := strings.TrimRight "/" ($page.GetPage $title).RelPermalink}}
|
{{$href := strings.TrimRight "/" ($page.GetPage $title).RelPermalink}}
|
||||||
|
<!-- if alias given, use alias, else title -->
|
||||||
{{$display := default $title (index $split 1)}}
|
{{$display := default $title (index $split 1)}}
|
||||||
{{if not $href}}
|
{{if not $href}}
|
||||||
{{$link := printf "<a class=\"internal-link broken\">%s</a>" $display}}
|
{{$link := printf "<a class=\"internal-link broken\">%s</a>" $display}}
|
||||||
|
|
Loading…
Reference in a new issue