fix: links to fragment on same page should not be made portable

This commit is contained in:
Daniël van de Giessen 2025-04-23 14:22:28 +02:00
parent 115a94122e
commit f9056d80d4
No known key found for this signature in database
GPG Key ID: 9F0EF4D3441C8163

View File

@ -7,7 +7,8 @@
{{- define "portable-link" -}}
{{- $destination := .Destination }}
{{- $isRemote := or (in .Destination ":") (strings.HasPrefix .Destination "//") }}
{{- if not $isRemote }}
{{- $isFragment := strings.HasPrefix .Destination "#" }}
{{- if and (not $isRemote) (not $isFragment) }}
{{- $url := urls.Parse .Destination }}
{{- $path := strings.TrimSuffix "/_index.md" $url.Path }}
{{- $path = strings.TrimSuffix "/_index" $path }}