Skip to content
Discussion options

You must be logged in to vote

@freshyill I can think of two possible solutions:

  1. You could keep your structure as-is, and probably use eleventyComputed to dynamically resolve kingdom from the /_data/ directory, like so:

    ---js
    {
      key: "insects",
      eleventyComputed: {
        kingdom(data) {
          return data[data.key];
        }
      }
    }
    ---
    
    {% for animal in kingdom %}
      <p>{{ animal.name }}</p>
    {% endfor %}

    Possibly better ways of doing that. I sometimes find JavaScript frontmatter confusing, but it works.

  2. Slight tweak to your /_data/ directory, but if you move the insects.json file into a subfolder, like /_data/dynamic/insects.json, you can reference it dynamically like so:

    ---
    kingdom: insects
    ---
    
    {% for animal in dynamic[

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@freshyill
Comment options

Answer selected by freshyill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants