Deconstruct and reconstruct frontmatter

I am wanting to use this formatting for my blog post front matter to create a image slider:

[[images]]
  src = "img1.jpg"
  alt = "alt1"
  stretch = "horizontal"
[[images]]
  src = "img2.jpg"
  alt = "alt2"
[[images]]
  src = "img2.jpg"
  alt = "alt1"
  stretch = "vertical"

The problem is that the internal templates for Opengraph and Schema do:

{{ range .Params.images }}{{ . }}{{ end }}

This means that the desired format is:

images = ["img1.jpg", "img2.jpg", "img3.jpg"]`

As such, all of the meta data from my frontmatter is blank since there is nothing located at .Params.images.


What I am looking for is either a way to put the src directly on .Params.images, or have a way to deconstruct and reconstruct it before and after the meta. Something like this:

{{ $Store := $.Params.images }}
{{ $images := slice }}
{{ range $.Params.images }}
  {{ $images = $images | append .src }}
{{ end }}
{{ $.Params.images = $images }}
{{- template "_internal/schema.html" . -}}
{{- template "_internal/opengraph.html" . -}}
{{ $.Params.images = $Store }}

I am sure I am over thinking this and the simple solution would be to build my own versions of schema.html and opengraph.html, I figured I would see if it is possible to write over a page/site variable with the Go logic.

It is not.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.