Can't access 11ty collection from config.yml

Hello!

I have an 11ty / NetlifyCMS site up and running. I have a .json file in my _data folder (_data/exampledata.json) like this:

[
 {
  "name": "name one",
  "id": "id one"
 },
 { ... }
]

I would like to make a relation widget in the CMS that would be able to choose items from this collection, using “name” as the value_field and search_field, but I can’t get it work, the widget always shows “No options”.

Things I’ve tried in my config.yml so far:

- { label: "Example", name: "example", widget: "relation", collection: "exampledata", value_field: "name", search_fields: ["name"] }

I’ve also tried registering the data as a custom collection in my .eleventy.js file:

eleventyConfig.addCollection("exampleDataCollection", (collection) => {
	const items = collection.getAll()[0].data.exampledata
	return items
})

and then include it in my config.yml:

- { label: "Example", name: "example", widget: "relation", collection: "exampleDataCollection", value_field: "name", search_fields: ["name"] }

Both approaches work when I’m just trying to render out the data in a template file though, but I cannot access the collection from the config.yml file. (I haven’t tried 11ty’s pagination yet, but I don’t need to build pages of this data, I’d only need it in the CMS as a “dropdown list” basically).

Thanks for any help!

Hi @bb4rn,

Netlify no longer manages the CMS: Introducing Decap CMS | Decap CMS | Open-Source Content Management System. We would not be able to provide any support about it.