fix: links to fragment on same page should not be made portable (#707)

This commit is contained in:
Daniël van de Giessen 2025-04-29 00:40:46 +02:00 committed by GitHub
parent 5cff108b34
commit 9405c4c3d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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 }}