hugo: fix link generation

For some inexplicable reason, the link render hook was failing, probably
caused by cases where goldmark was called recursively by shortcodes.

This change changas the render hook to use the global `pages` pointer
instead of the .Pages pointer of the render hook context. Seems to work.

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-08-08 16:06:53 +02:00
parent ba472d8893
commit 812ba366b4
1 changed files with 3 additions and 3 deletions

View File

@ -13,7 +13,7 @@
{{- else if (strings.HasPrefix $url "/") -}}
{{ if (strings.HasSuffix (urls.Parse $url).Path ".md") }}
{{/* abs path to markdown file, use ref */}}
{{ $url = (ref .Page $url) }}
{{ $url = (ref page $url) }}
{{ end }}
<a class="link" href="{{ $url }}">{{ .Text | safeHTML }}</a>
{{- else -}}
@ -21,12 +21,12 @@
{{- if (strings.FindRE `([^_]|^)index.md` $url 1) -}}
<a
class="link"
href="{{ ref .Page (strings.Replace $url "index.md" "_index.md") }}"
href="{{ ref page (strings.Replace $url "index.md" "_index.md") }}"
>{{ .Text | safeHTML }}</a
>
{{- else -}}
{{/* relative link, use ref */}}
<a class="link" href="{{ ref .Page $url }}"
<a class="link" href="{{ ref page $url }}"
>{{ .Text | safeHTML }}</a
>
{{- end -}}