mirror of
https://github.com/tiennm99/iammiti99.git
synced 2026-10-14 10:18:44 +00:00
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:
1 parent
3b7c0e94ce
commit
51a908b6b4
2 files changed
+2
-2
No files matched your search
@@ -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 -}}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user