Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dots in Global Data Files are used for dot-pathing instead of preserved in key name #1242

Closed
Dermah opened this issue Jun 9, 2020 · 3 comments · Fixed by #1912
Closed

Dots in Global Data Files are used for dot-pathing instead of preserved in key name #1242

Dermah opened this issue Jun 9, 2020 · 3 comments · Fixed by #1912
Labels
breaking-change This will have to be included with a major version as it breaks backwards compatibility. bug

Comments

@Dermah
Copy link

Dermah commented Jun 9, 2020

Describe the bug
If a data file has dots in the file name, the dots describe an object path that the data in the file is available at.

To Reproduce
In an eleventy project:

  1. Create a file at _data/sites/11ty.dev.json that just contains:
    {}
  2. Create a file at index.liquid that just contains:
    {{sites | log}}
  3. Run npx @11ty/eleventy
  4. See console output:
    { '11ty': { dev: {} } }

Expected behavior
I don't know if this is actually expected behaviour, but I would have assumed it would output

{ '11ty.dev': {} }

The 11ty docs seem to operate under this assumption, because sites with dots in the filename don't show up on the leaderboard due to the unexpected dot-path behaviour.

Environment:

  • OS and Version: macOS 10.15.5
  • Eleventy Version: 0.11.0

Additional context

@zachleat
Copy link
Member

zachleat commented Sep 7, 2020

Yes this is absolutely a bug!

@zachleat
Copy link
Member

zachleat commented Sep 7, 2020

I would love a PR on this although I don’t think Dermah@0b88d8d is quite accurate? folder["sub.folder"] works but fol.der["subfolder"] wouldn’t?

Snapstromegon added a commit to Snapstromegon/eleventy that referenced this issue Jul 29, 2021
Dots in the global datafile path leads to data beeing incorrectly nested.
This commits changes the behavior so a datafile a.b.json will create an entry with data["a.b"] instead of data.a.b.
The old behavior was a bug according to 11ty#1242.

The implementation makes use of lodashs set and get functions which also take object paths in array form instead of string. That way we can implement this safely.

Signed-off-by: Raphael Höser <raphael@hoeser.info>
Snapstromegon added a commit to Snapstromegon/eleventy that referenced this issue Jul 29, 2021
This commit adds an additional testcase for 11ty#1242 to avoid future regressions.

Signed-off-by: Raphael Höser <raphael@hoeser.info>
zachleat added a commit that referenced this issue May 10, 2022
@zachleat zachleat added the breaking-change This will have to be included with a major version as it breaks backwards compatibility. label May 10, 2022
@zachleat zachleat added this to the Eleventy 2.0.0 milestone May 10, 2022
@zachleat
Copy link
Member

Merged #1912, this will ship with 2.0.0-canary.10.

Thank you @Snapstromegon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will have to be included with a major version as it breaks backwards compatibility. bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants