-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Support custom extensions for data providers #736
Comments
Hm, could you workaround with collection (glob flavour) or data files until #117 is implemented? |
How would collections help? And to be clear, I meant data files. If it wasn't clear in the issue above let me know and I'll rewrite. Basically, let me say that _data/cats.geojson is a valid data file by telling 11ty to look for *.json and *.geojson. The default would be *.json. |
Had a similar problem. I wanted to create a collection out of json files in my data folder. Eleventy treated them as individual data files. So I created a directory data file in the JS format which means I can use Node to manually load, parse and return the files as JSON objects:
Might be overkill but worked for me :) Edit: Of course depending on the size of your files you might want to switch from sync to async file operations |
I had a similar approach like @saenglert in mind. |
Glob collection would be https://www.11ty.io/docs/collections/#getfilteredbyglob(-glob-) |
I don't get that how that would help for a data file though? Basically I want foo.geojson to be available as foo in my templates. It's not a collection, just data. I'd like Eleventy to basically let me configure: "In _data, what files do I consider JSON files." Does that make sense? |
Yes it does, @cfjedimaster. Now my approach returns the data as unsorted array. You want to access your files by filename. This means some modifications are required. |
Ok, so when I wrote this bug, I thought maybe 117 wasn't going to cover it. If you think it will, I'll gladly close this as a dupe. :) Thanks! |
You probably can do it with new custom data files feature that just get merged #798 |
#635 #798 aren’t quite aliasing but since it’s JSON I think that lovely addition by @gloryofrobots will solve this particular issue nicely. Just for pedantic reasons I’ve filed #801 if people want fancier data file aliasing moving forward. #207 is the issue for template file aliasing. |
Closing as a duplicate of #630. Look for this feature in 0.10.0! |
Is your feature request related to a problem? Please describe.
Note, I don't think this is the same as #117, but I could be wrong.
I do a lot of work with GeoJSON files (https://geojson.org/). They are JSON files but (typically) use the .geojson file extension. Putting one of these in _data will not work because 11ty will not recognize it as JSON.
Describe the solution you'd like
I'd like a configuration setting that would let me specify a file extension pattern, or list, to be treated as JSON.
Describe alternatives you've considered
Renaming the file. :) That works.
The text was updated successfully, but these errors were encountered: