Here is my dir structure.
-- content/
---- about/
---- blog/
---- work/
------ anim/
-------- anim-01/
------------ _index.md
-------- anim-02/
------------ _index.md
------ art/
-------- art-01/
------------ _index.md
I have a short code based off the example here in themes/site/layouts/shortcodes/gallery.html.
My themes shortcodes/gallery.html:
{{- $pathURL := .Get "pathURL" -}}
{{- $path := .Get "path" -}}
{{- $sections := readDir $path -}}
{{- range $sections | intersect (where $sections ".Name" "!=" "_index.md") }}
<a href="{{ $pathURL }}{{ .Name | relURL }}">{{ .Name }}</a>
{{- end }}
an example subdir /work/anim/anim-01/_index.md
---
title: 'Animation 01'
categories:
- Animation
- Drawing
- Traditional
---
**animation** dolor sit amet...
My work/_index.md:
---
title: 'Work'
date: ''
---
**Work** Quisque mattis volutpat lorem vitae feugiat.
{{< gallery path="/content/work/" pathURL="/" >}}
which produces “_index.md anim art code” at the bottom, live in work/.
Now to the issue. I’d like to make the following arrays:
$dirs array which contains the the entries inside the $files array excluding the initial “_index.md” entry.
$subdirs array which contains the subdirs of the $dirs array, “anim-01, anim-02, art-01” etc.
$categories array that contains the categories inside each subdir [Animation, Drawing, Traditional], [Animation, Digital]".
Ultimately I’d like this structure in my shortcode:
<a href="{{ $dirs }}/{{ $subdirs }}" class="{{ $categories }}">anim/anim-01/</a>
A literal:
<a href="anim/anim-01/" class="animation drawing traditional">anim/anim-01/</a>
I’m pretty confused how to go about it and would appreciate any help.