timwis / jkan

A lightweight, backend-free open data portal, powered by Jekyll
https://jkan.io
MIT License
218 stars 310 forks source link

Netlify CMS shows empty category when category is a string #235

Open timwis opened 1 year ago

timwis commented 1 year ago

JKAN supports two types of values for a dataset's category: a string (for a single category), or an array of strings (for multiple categories).

name: City Budget
category: Finance
name: Bicycle Lanes
category:
  - Transportation
  - Planning / Zoning

Netlify CMS is configured to allow multiple values for this field. Unfortunately, it seems that if you edit a dataset with a string value (as in the first example above), the UI shows the field as blank.

Fortunately, if you save, it keeps the existing category value (unless you change the category), so it won't lose the value, but it can be confusing for users.

It would be great if we could submit a PR to Netlify CMS to fix this. But in the meantime, it might be worth adding a linter of some sort to JKAN to enforce a schema. We could also add it to a jekyll upgrade-jkan CLI (to fix any string values).

EDIT: I previously thought this would silently drop existing category values, but I've confirmed that it doesn't.