So, thankfully, Netlify CMS allows editing of JSON files, and it is easy to set up. I cannot iterate how completely and unequivocally awesome this is. There is only one small catch that is preventing a full win. The additional frontmatter added by Netlify CMS does not jive with fullcalendar.js.
Fullcalendar expects JSON files containing calendar data to possess the following strict format:
[
{
"title": "Another Example Event",
"start": "2021-10-31T21:30:00",
"end": "2021-11-01T04:00:00",
"allday": false,
"url": "/event/halloween"
},
{
"title": "Example Event",
"start": "2021-09-26T12:43:00",
"end": "2021-09-26T13:30:00",
"allday": false,
"url": "/event/example-event/"
}
]
But, Netlify CMS adds a parent declaration to the data, mirroring its own configurational structure.
{
"events": [ #<--- fullcalendar.js does not like this, and will fail to render data.
{
"title": "Another Example Event",
"start": "2021-10-31T21:30:00",
"end": "2021-11-01T04:00:00",
"allday": false,
"url": "/event/halloween"
},
{
"title": "Example Event",
"start": "2021-09-26T12:43:00",
"end": "2021-09-26T13:30:00",
"allday": false,
"url": "/event/example-event/"
}
]
}
As mentioned above, the addition of the parent declaration is a result of Netlify CMS’s own configuration:
- label: "Calendar"
name: "calendar"
file: "content/event/index.json"
description: "Event List"
extension: "json"
fields:
- label: Events
name: events # <--- It is here that gets us in trouble.
widget: list
fields:
- {label: Url, name: url, widget: string, required: false, hint: "Url of events."}
- {label: All-Day, name: allday, widget: boolean, default: false}
- {label: End, name: end, widget: datetime, format: YYYY-MM-DDTHH:mm:ss}
- {label: Start, name: start, widget: datetime, format: YYYY-MM-DDTHH:mm:ss}
- {label: Title, name: title, widget: string}
Understanding it is necessary for Netlify CMS to have the structure that is does, is there anyway to prevent it from rendering the additional parental declaration?
Sorry if this is worded poorly, I need to sleep now.