CLI: add mechanism to pass callbacks as plugin options through metalsmith.json

Author: webketjeCreated May 1, 2022Updated Sep 5, 2023

The aim would be to allow function type options to be passed through metalsmith.json, so one is not forced to use the JS approach, say if for example we want to use the slug option of @metalsmith/permalinks: https://github.com/metalsmith/permalinks#custom-slug-function

javascript
ms.use(permalinks({ slug(path) { return path } })

There should be a way to refer to functions in another file in Metalsmith directory & its node_modules we could think of something like:

json
{
  "plugins": [
     {"@metalsmith/permalinks": { "slug": "file://./config/permalinks" }}
  ]
}

The issue is what will the "marker" be. file://? function:// ? @.

Also, if something generic is used, like file://, name collision could occur easily, but it would also allow to construct a metalsmith.json from separate config files loaded into placeholders ( a bit like a lot of MVC frameworks allow to split config over multiple files, eg spring boot, laravel) This feature will add some parsing overhead as it needs to deep-walk all plugin options and replace values matching the marker with their respective exports.