fix(theme): pass TrimPrefix arguments in prefix-then-string order

strings.TrimPrefix takes the prefix first. With the arguments swapped,
resources.Get received "/" and returned the root directory, so any local
params.avatar failed the build with "only available for image resources".
This commit is contained in:
tiennm99 committed 2026-10-03 12:30:08 +07:00
1 parent 3b7c0e94ce
commit 51a908b6b4
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@
{{- $local := false -}}
{{- $res := "" -}}
{{- if not $isHTTP -}}
{{- $clean := strings.TrimPrefix $avatar "/" -}}
{{- $clean := strings.TrimPrefix "/" $avatar -}}
{{- with resources.Get $clean -}}
{{- $res = . -}}
{{- $local = true -}}
+1 -1
View File
@@ -86,7 +86,7 @@
{{- /* Avatar preload: only for `static/`-served paths. When avatar resolves as an
`assets/` resource the <picture> pipeline emits its own srcset/fetchpriority
and a fixed-path preload would be wasted (different filename + format). */ -}}
{{- if and site.Params.avatar (ne (site.Params.preloadAvatar | default true) false) (not (strings.HasPrefix site.Params.avatar "http")) (not (resources.Get (strings.TrimPrefix site.Params.avatar "/"))) }}
{{- if and site.Params.avatar (ne (site.Params.preloadAvatar | default true) false) (not (strings.HasPrefix site.Params.avatar "http")) (not (resources.Get (strings.TrimPrefix "/" site.Params.avatar))) }}
<link rel="preload" as="image" href="{{ site.Params.avatar | strings.TrimPrefix "/" | relURL }}" fetchpriority="high" />
{{- end }}
{{- /* Fingerprinted + minified CSS via Hugo's resource pipeline.