Architect the page generator component
Define an architecture for the page generator component. The page generator operates on the files in the "pages" family, applies the specified template, which is retrieved from the UI catalog, and updates the value of the contents
property on the vinyl file with the template result.
Each page should be able to specify a layout using the page-layout
AsciiDoc document attribute. If this attribute is not defined, then the layout defined by the playbook property ui.defaultLayout
should be used. If that property is not specified, then the layout named default
should be used.
Prior to compiling the layout, all the partials and helpers from the UI catalog need to be registered with the Handlebars engine. This compilation should probably be done first, before the pages are processed, though it could be done lazily as well.
In order to apply the template, it's necessary to prepare and pass a UI model (i.e., the template context). The main variable in this model is contents
, which comes from the contents
property on the vinyl file (which, at this stage, holds the HTML generated by Asciidoctor). Here's a rough sketch of the UI model that will to be passed:
{
site: {
url,
title,
domains,
},
title,
contents,
description,
keywords,
domain: {
name,
versioned,
url,
root,
version: {
string,
},
versions,
},
versions,
canonicalUrl,
editUrl,
uiRootPath,
siteRootUrl,
home,
}
(It's understood that the context for the UI model is page, thus the "title" variable is effectively "page title").
It may take a few iterations to get the UI model exactly the way we want it. It's also missing the navigation and breadcrumbs stuff at this point since that component is not yet ready.
Note that the site property should be a model that's shared by all pages so it doesn't have to be recomputed on each page. The domain should be just a reference to an entry in the domains collection.
In addition to domain and domains, I think we should go ahead and add component and components back in, just for convenience. The components property is a subset of the domains property, since it only has the domains which are themselves components (not aspects).
Acceptance criteria:
-
Define behavior of page generator component -
Define API methods, inputs, and outputs -
Decide the name of the package -
Define the state, if any, the component maintains