tableflip / tune

:trumpet: Client for the TABLEFLIP static site generator
0 stars 1 forks source link

Refactor Projects and Pages collections - Part 2 #19

Open richsilv opened 8 years ago

richsilv commented 8 years ago

Storing page (or project) data and schema at the top level of a collection is inconvenient from the perspective of UI components. It means that in order to render the appropriate editor component (and potentially even a preview component) we need the entire page doc to lookup the schema relating the the field in question.

Instead, we should store field values and their schemas together in the document tree:

{
  ...
  content: {
    foo: {
      value: 'bar',
      schema: {
        type: 'text',
        maxLength: 10
      }
    }
  }
  ...
}

This will involve serialising and deserialising the data when we sync with the repo, which is an added complication, but should make everything much easier to deal with in the app.

bmordan commented 8 years ago

I think this would make it more maintainable. I can imagine myself updating a content.json - and yes then forgetting to update the schema.json