Hi,
Looking for some help on using dynamic variable names within data file locations. I can’t seem to get things working.
Firstly, here is my structure for context (my data_dir is docs):
docs/
├─ users/
│ ├─ general/
│ │ ├─ users.md
│ ├─ config.json
I currently have this loop working fine as the data file location is hard coded:
## Table of contents
<ul>
{% for query in site.data.users.config %}
<li>
<a href="#{{ query.name | downcase | replace: " ", "-"}}">
{{ query.name }}
</a>
</li>
{% endfor %}
</ul>
However, I’m trying to essentially get from this:
{% for query in site.data.users.config %}
to something like this using the parent front matter variable:
---
parent: Users
---
{% for query in parent.config %}
I’ve tried this which did not work: {% assign x site.data.{{ parent | downcase }} %}
and using x.config
If I print out the x variable above then I do start to get ```{“users”=>{“config”=>[{``…`
I’m at a bit of a loss for how to proceed. Any help would be much appreciated!