hardforkio / homepage

Hardforks homepage. Open source as an example on how we work and code.
https://hardfork.io
MIT License
0 stars 0 forks source link

Make i18n typesafe when using folder collections #336

Open Bakkhos opened 4 years ago

Bakkhos commented 4 years ago

Currently the JSON data imported by /src/data/index.tsx files is not type checked in those cases where one is using importAll (rather than import) - that is, in case of folder collections.

Ideally these types would be checked somehow, so that the app does not crash when the json files are corrupt (e.g. because netlify cms writes unexpected things in there)

Bakkhos commented 4 years ago

The simplest way probably is to go and change netlify cms to write a single json file containing a list, instad of one json file per collection entry. Even better would be to output typescript right away, with type definitions for each collection automatically derived from the widgets and the schema.

Then we can dump importAll entirely and just use import.