mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 23:04:05 -06:00
Replacing "internal-link broken" with link to asset
This commit is contained in:
parent
d56a58044d
commit
f63cc508b7
@ -35,23 +35,26 @@
|
||||
{{$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}}
|
||||
<!-- heading link -->
|
||||
|
||||
<!-- if alias given, use alias, else title -->
|
||||
{{$display := default $title (index $split 1)}}
|
||||
<!-- REMOVE SUBFOLDER FROM TITLE -->
|
||||
{{$display := index (last 1 (split $display "/")) 0}}
|
||||
|
||||
{{if eq (string ($page.GetPage $title)) "nopPage"}}
|
||||
{{$path := index $split 0 | relURL}}
|
||||
{{$link := printf "<a href=\"%s\" rel=\"noopener\" class=\"internal-link\">%s</a>" $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}}
|
||||
<!-- if alias given, use alias, else title -->
|
||||
{{$display := default $title (index $split 1)}}
|
||||
<!-- ADDED LINE TO REMOVE SUBFOLDER FROM TITLE: -->
|
||||
{{$display := index (last 1 (split $display "/")) 0}}
|
||||
{{if not $href}}
|
||||
{{$link := printf "<a class=\"internal-link broken\">%s</a>" $display}}
|
||||
{{$content = replace $content . $link}}
|
||||
{{else}}
|
||||
{{$fullhref := printf "%s%s" $href $block }}
|
||||
{{$link := printf "<a href=\"%s\" rel=\"noopener\" class=\"internal-link\" data-src=\"%s\">%s</a>" $fullhref $href $display}}
|
||||
{{$content = replace $content . $link}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user