{{ with .Get 0 }}
{{ with $.Page.Resources.Get . }}
{{ .Content }}
{{ else }}
{{ errorf "The %s shortcode was unable to get %s. See %s" $.Name . $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %s shortcode requires one positional parameter. See %s" .Name .Position }}
{{ end }}
Thank you so much. It works. I have tried .Page.Resources.Get without $, what is the difference between them?
Also, it seems like with the injected resource, I cannot get the correct TOC. Is there any solution for this?
I forgot something. You cannot indent the {{ .RawContent }} line in the shortcode by 4 or more spaces. If you do, the first line of the content is treated as a code block. So let’s trim the leading whitespace with the {{- action delimiter.
{{ with .Get 0 }}
{{ with $.Page.Resources.Get . }}
{{- .RawContent }}
{{ else }}
{{ errorf "The %s shortcode was unable to get %s. See %s" $.Name . $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %s shortcode requires one positional parameter. See %s" .Name .Position }}
{{ end }}