mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-25 21:16:21 +00:00
fix links being broken for pages with spaces
This commit is contained in:
parent
9c04ca0266
commit
714b4fcfa3
1 changed files with 6 additions and 5 deletions
|
@ -1,10 +1,11 @@
|
|||
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
|
||||
{{$trimmed = replace $trimmed "%20" "-" }}
|
||||
{{$external := strings.HasPrefix $trimmed "http" }}
|
||||
{{$dashedurl := replace $trimmed "%20" "-" }}
|
||||
{{$external := strings.HasPrefix $dashedurl "http" }}
|
||||
{{- if $external -}}
|
||||
<a href="{{ $trimmed }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
||||
<a href="{{ $dashedurl }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
||||
{{- else -}}
|
||||
{{$fixedUrl := (cond (hasPrefix $trimmed "/") $trimmed (print "/" $trimmed)) | urlize}}
|
||||
{{$rooted := strings.TrimRight "/" (.Page.GetPage $fixedUrl).RelPermalink }}
|
||||
{{$spacedurl := replace $trimmed "%20" " " }}
|
||||
{{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}}
|
||||
{{$rooted := default $spacedurl (strings.TrimRight "/" (.Page.GetPage $spacedurl).RelPermalink) }}
|
||||
<a href="{{$rooted}}" rel="noopener" class="internal-link" data-src="{{$rooted}}">{{ .Text | safeHTML }}</a>
|
||||
{{- end -}}
|
Loading…
Reference in a new issue