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

Reduce ambiguity in config options #402

Open
webketje opened this issue Jan 30, 2024 · 0 comments
Open

Reduce ambiguity in config options #402

webketje opened this issue Jan 30, 2024 · 0 comments

Comments

@webketje
Copy link
Member

Currently all metalsmith options can be set in a CLI format slightly different from using dedicated API methods like ignore() and destination(). Those are distinct in that calling metalsmith.destination('different/path') from within a plugin will actually alter the destination path for all files, as metalsmith.destination() is retrieved inside each metalsmith.writeFile call, whereas metalsmith.ignore() has no impact on ignored files when run from inside a plugin (though it may affect plugins relying on the output of metalsmith.ignore() and thus have unexpected results).

But there may be some uses where this is useful, so it must first be assessed whether it is possible to reproduce a build with a new instance of metalsmith without losing access to necessary info. In that regard I think it may be useful to add a metalsmith.entries(fileObj) method to programmatically set the ms entries. But in general I think the expectation from users is that a single Metalsmith build should be immutable, so a plugin cannot alter the user-defined source property.

Related to #280, consider migrating some 'methods-as-options' like source, destination, ignore, clean, frontmatter, concurrency to a separate options or config method:

metalsmith.options({
  source: 'src',
  destination: 'build',
  frontmatter: true,
  // methods like these would remain because they have other uses
  // like checking whether the watcher is enabled, but options method would allow setting default values for them
  watch: {},
  metadata: {},
  env: {}
})
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