Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'renderContext' (=locals/data) option? #190

Open
webketje opened this issue Nov 20, 2023 · 0 comments
Open

Add 'renderContext' (=locals/data) option? #190

webketje opened this issue Nov 20, 2023 · 0 comments

Comments

@webketje
Copy link
Member

To avoid the usecase at metalsmith/collections#79 (comment) 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant