hugo: add support for absolute markdown links

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-06-12 15:28:29 +02:00
parent ac4d311f60
commit b21e0573af
1 changed files with 4 additions and 1 deletions

View File

@ -11,7 +11,10 @@
{{- partialCached "icon" "open_in_new" "open_in_new" -}}
</span></a>
{{- else if (strings.HasPrefix $url "/") -}}
{{/* absolute link, use url as-is */}}
{{ if (strings.HasSuffix (urls.Parse $url).Path ".md") }}
{{/* abs path to markdown file, use ref */}}
{{ $url = (ref .Page $url) }}
{{ end }}
<a class="link" href="{{ $url }}">{{ .Text | safeHTML }}</a>
{{- else -}}
{{/* check if the file links to index.md */}}