jondashkyle / nanopage

super handy utilities for traversing flat content state
Apache License 2.0
42 stars 4 forks source link

Specification #13

Closed jondashkyle closed 6 years ago

jondashkyle commented 6 years ago

Talking about this with @jongacnik this recently, we began thinking it could be useful to create a formal specification for the type of data structure nanopage digests. This would then be applied to hypha, enoki, and other libraries could hook into this and reference it, too. A good example is monoimage.

The discussion surrounding image sizes is a good example of what could be covered in this specification. The flat-structure and paths as keys is another good example.

Another discussion could be around urls. For instance, hypha generates url, path, and source keys, each which behaves differently and is at the moment somewhat convoluted.

Part of this specification could be a testing tool to ensure data is structured correctly. In this way, you wouldn’t be required to follow step-by-step to follow the specification, but could simply evaluate your tool against the specification.

Looking to collect some good resources here, and perhaps we can create a repository for this.

@jongacnik @s3ththompson

jongacnik commented 6 years ago

Agreed. You already mentioned, but just to concur, the main items I see to address:

What's cool is seems like the spec really doesn't need much. I feel like once we agree on the above the spec is more or less there, since any other keys (things like title, text, etc) are really up to the implementer to decide.

FWIW, gonna give my initial 2-cents on the above 6:

More or less, the shape based on above looks like:

{
  '/': {
    url: '/'
  },
  '/about': {
    url: '/about',
    title: 'About',
    text: 'Beep Boop',
    _loaded: true
  },
  '/about/file.jpg': {
    url: '/content/about/file.jpg',
    sizes: {
      500: '/content/about/file-500.jpg',
      1000: '/content/about/file-1000.jpg',
      1600: '/content/about/file.jpg', // full size file
    },
    dimensions: {
      width: 1600,
      height: 1200,
      ratio: 75
    }
  }
}

Happy to expand if any q's!

jondashkyle commented 6 years ago

Gonna close this in favor of the conversation being moved to a separate schema repository.

s3ththompson commented 6 years ago

@jondashkyle ping me when you start the schema respository! I couldn't get to this earlier in the week but I think this is a great idea and have a few things to contribute.

Generally, though +1 to everything above