fix links being broken for pages with spaces
This commit is contained in:
parent
85dea2ed79
commit
15ff24a483
@ -1,10 +1,11 @@
|
|||||||
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
|
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
|
||||||
{{$trimmed = replace $trimmed "%20" "-" }}
|
{{$dashedurl := replace $trimmed "%20" "-" }}
|
||||||
{{$external := strings.HasPrefix $trimmed "http" }}
|
{{$external := strings.HasPrefix $dashedurl "http" }}
|
||||||
{{- if $external -}}
|
{{- if $external -}}
|
||||||
<a href="{{ $trimmed }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
<a href="{{ $dashedurl }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{$fixedUrl := (cond (hasPrefix $trimmed "/") $trimmed (print "/" $trimmed)) | urlize}}
|
{{$spacedurl := replace $trimmed "%20" " " }}
|
||||||
{{$rooted := strings.TrimRight "/" (.Page.GetPage $fixedUrl).RelPermalink }}
|
{{$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>
|
<a href="{{$rooted}}" rel="noopener" class="internal-link" data-src="{{$rooted}}">{{ .Text | safeHTML }}</a>
|
||||||
{{- end -}}
|
{{- end -}}
|
Loading…
Reference in New Issue
Block a user