layouts
layouts copied to clipboard
Add 'renderContext' (=locals/data) option?
To avoid the usecase at https://github.com/metalsmith/collections/issues/79#issuecomment-1027474334 the user could be given the option to transform the render context passed to a template. By default this would be (backwards-compatible):
function renderContext(fileMeta, path, globalMeta) {
return { ...globalMeta, ...fileMeta }
}
The collections use case can then use a single collections
property both on the file & global meta, and the renderContext can be remapped:
function renderContext(fileMeta, path, globalMeta) {
return { ...globalMeta, ...fileMeta, collections: { all: globalMeta.collections, own: fileMeta.collections }}
}
Not to mention some manual data imports could be added as well