adobe / helix-pipeline

request | markdown | html | response
https://www.project-helix.io
Apache License 2.0
31 stars 19 forks source link

selector dispatching/routing #169

Closed kptdobe closed 5 years ago

kptdobe commented 5 years ago

If you have 2 different rendering for some of your website pages, you would either need to code the 2 renderings in your single html.htl or need to know how to "dispatch" the incoming request and use ESI to include the proper rendering via a selector (you can find an example of this approach in https://github.com/kptdobe/helix-dispatch)

Having one single html.htl is not enough even for basic websites where there is always a page that needs to be rendered differently.

The idea here is to offer a simple way for the developer to write a dispatch function that would determine which HTL renderer to use for a give incoming request and transparently handle the ESI include for him.

cc @trieloff

trieloff commented 5 years ago

Just mocking what an API could look like:

const router = require('@adobe/helix-pipeline/router');

function pre(payload) {
  return router(payload)
    .url('/', 'home')
    .url('/*', 'marketing')
    .url('/*/docs/*', 'docs')
    .content(content => true, 'about');
}