Configure .YML file to read .JSON correctly

Hi, I have a .json file containing a list of items that populate a menu. The basic structure is:

[
  {"slug": "content", "title": "Contact us"},
  {"slug": "about", "title": "About us"}
  ...
]

I’ve tried to recreate this array of objects within the my .yml file like so:

collections:
  - name: "menus"
    label: "Menus"
    files:
    - label: "Menu"
      name: "menu"
      file: "_menu/urls.json"
      widget: "list"
      fields:
        - label: "Menu"
          name: "menu"
          widget: "object"
          fields:
          - { label: "URL", name: "slug", widget: "string"}
          - { label: "Menu title", name: "title", widget: "string"}

However, when I try to view this (either locally or on the actual site) I only see empty fields, and only one entry. I was assuming that if I get my .yml correct then I would see all the objects in my .json array?

Any help appreciated - thanks!

Netlify CMS doesn’t support root level arrays yet, it would need to be wrapped into an object. Here’s the issue to follow: Feature: edit data files with a list/array at root level · Issue #531 · netlify/netlify-cms · GitHub

1 Like