get internal links from page resources

This commit is contained in:
Ben Goldsworthy 2025-05-06 19:27:50 +02:00
parent e9185cf1e5
commit 5aec4874b6
No known key found for this signature in database

View file

@ -84,7 +84,15 @@
<ul>
{{- range . -}}
{{ if eq ( printf "%T" . ) "map[string]interface {}" }}
<li><a href="{{ .link }}">{{ .title | safeHTML }}</a></li>
{{- if .src -}}
{{- $src := $.Page.Resources.GetMatch .src -}}
{{- if ( not $src ) -}}
{{- errorf "No Page Resource found for src '%q' (%q).\n\n\tAvailable Page Resources are:\n\t\t%v" ( $.Get .src ) $.Page.File.Path $.Page.Resources -}}
{{- end -}}
<li><a href="{{ $src.RelPermalink }}">{{ .title | $.RenderString | safeHTML }}</a></li>
{{- else -}}
<li><a href="{{ .link }}">{{ .title | $.RenderString | safeHTML }}</a></li>
{{- end -}}
{{ else }}
<li><a href="{{ . }}">Link</a></li>
{{ end }}