I am playing with the new resources.Get
function thinking that maybe I can use it as an alternative to Page Bundles for older projects that I haven’t converted yet.
In my config I entered assetDir = "static"
(pleased to confirm that this works, creating symlinks under /assets/ didn’t work for me).
Now in each post I have the following frontmatter parameter image= "/images/1.jpg"
In the template I first tried the following:
{{ $path := .Params.image }}
{{ $thumb := resources.Get $path | safeHTML }}
And <img src="{{ $thumb | absURL }}"/>
However the above is outputting the Go templates unsafe operation error img src="#ZqotmplZ"
So after searching a bit I tried the following based on this old forum post:
{{ $thumb := (printf "/%s" (resources.Get .Params.image)) | safeHTML }}
Now I’m not getting the Go templates error but instead the URL is printed wrong:
http://localhost:1313/Resource%28image:%20images/1.jpg%29
Also tried variations with safeURL
and safeHTMLAttr
but I got the same result.
Any pointers?