Skip to content

The navigation plugin is not working correctly with computed data. #4134

@Eliezer516

Description

@Eliezer516

First of all, thank you very much for this project. My problem is the following: I'm using the 11ty Navigation Plugin. I have a main directory with other subdirectories, each with its respective notes in Markdown. Inside each one, I have a JSON file with the same name as the folder to add frontmatter to each of the notes. For example:

My directory has the following structure:

post/
  post-1.md
  post-2.md
  index.md
  ...
  subfolder/
    otro-post.md
    index.md
    ...

And in each one, I have my data file:

// post.json
{
  "layout": "base.njk",
  "eleventyComputed": {
    "eleventyNavigation": {
      "key": "{{ title }}",
      "parent": "..."
    }
  }
}

For some reason, when I use the following code snippet in one of my files, nothing is displayed:

// index.njk
{{ collections.all | eleventyNavigation | eleventyNavigationToHtml | safe }}

While doing some testing, I realized it was happening because the Navigation Plugin isn't correctly "receiving" the properties. I thought it was an issue related to computed properties, until I tried this and changed my mind:

<ul>
{%- for post in collections.post -%}
  <li>{{ post.data.title }} - {{ post.data.eleventyNavigation.key }}</li>
{%- endfor -%}
</ul>

Basically, I changed my mind because it shows exactly what I would expect.
So, long story short, I don't know what's going on. As I mentioned earlier, I think it's a problem with the Navigation Plugin because it's not correctly getting the necessary properties when they are calculated in a computed way, but internally, they are behaving correctly.

PD: My native language is Spanish, so I'm using a translator to write this message. 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions