Skip to content

Files #7

@jondashkyle

Description

@jondashkyle

here’s a trip. consider how nanopage referenced pages with a nested object. that was removed and now there is a simple regex against the flat state.content object. what if we did the same for files? in this case, you could have state.content which looks like this:

{
  '/': {
    title: 'Index'
   },
  '/example.jpg': {
    name: 'example',
    extension: 'jpg'
  }
}

started thinking about this when i implemented the updated find utility, which does this and would nicely work with passing filenames:

// updated find utility
if (typeof value.url === 'string') {
    return state.content[resolve(value.url, url)]
}

// example usage
page().find('test.jpg').v()

should likely update the pages regex to ensure there is no extension. likewise, should update files to look more like pages, but ensure there is an extension. also, perhaps we could pass an argument into the pages and files utils which returns a glob of children.

page('/example').pages(true).v()
// returns /example/one, /example/two, /example/two/child, etc…

this way we could dynamically add pages to a router without a bunch of rogue files ended up in there:

// choo router example
page('/').pages(true).keys().forEach(href => app.route(href, view(state, emitter.emit))

// want all your files?
page('/').files(true).v()

might be getting a little obscure with that router example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions