Hello,
as it is not possible to get data from inner shortcodes or siblings from inner shortcodes I tried the following approach to create a gallery. My issue is that when clicking on an image it should open in a lightbox and inside a lightbox there should be buttons to the previous and next image. All that without JavaScript as I have done several times already with Zola, it just seems impossible with hugo. On my final approach to accomplish that, I tried unsuccessfully to use a store.
The markdown file:
+++
…
+++
Some text
{{< gallery >}}
{{< gallery_lightbox path="000.png" >}}
{{< gallery_lightbox path="001.png" >}}
{{< gallery_lightbox path="002.png" >}}
{{< /gallery >}}
The gallery shortcode
{{- .Page.Store.Set "images" slice -}}
{{- .Page.Store.Add "imgaes" "foo" -}}
<pre>images in gallery: {{ .Page.Store.Get "images" -}}</pre>
<div>
{{- .Inner -}}
</div>
<pre>images in gallery: {{ .Page.Store.Get "images" -}}</pre>
The gallery_lightbox shortcode
{{- $image := .Page.Resources.Get (.Get "path") -}}
{{- .Page.Store.Add "images" $image -}}
<pre>image in gallery_lightbox: {{ $image }}</pre>
<pre>images in gallery_lightbox: {{ .Page.Store.Get "images" }}</pre>
The result
<pre>images in gallery: [foo]</pre>
<div>
<pre>image in gallery_lightbox: 000.png</pre>
<pre>images in gallery_lightbox: [foo 000.png]</pre>
<pre>image in gallery_lightbox: 001.png</pre>
<pre>images in gallery_lightbox: [foo 000.png 001.png]</pre>
<pre>image in gallery_lightbox: 002.png</pre>
<pre>images in gallery_lightbox: [foo 000.png 001.png 002.png]</pre>
</div>
<pre>images in gallery: [foo]</pre>
Is this working how it is expected? Using other values instead of .Page in .Page.Store does either not work (PAGE) or not change anything (page).
How to accomplish such a allegedly relative simple task?
edit: I know such things seem like they could be done in the frontmatter or by .Page.Resources.Get ... but using shortcodes here would have the neat effect that the elements of the gallery (the inner shortcodes) do not have to be homogeneous.