3

Metalsmith's documentation does not explain much about the path() function: #path(paths...): Resolve any amount of paths... relative to the working directory. This is useful for plugins who want to read extra assets from another directory, for example ./templates. That's it. That's the sum total of the documentation.

What arguments are expected and what do they do?

What I want to do is: Process different source directories according to different Metalsmith plugins. This seems to require me to create multiple templates/ directories under the separate source directories. If I want metalsmith-templates to look for templates under ../templates rather than ./templates, I would assume path() can do that... but in the absence of any meaningful documentation, I have no way to anticipate how to do it, or even whether it will work at all (short of reading the source code).

James Harkins
  • 99
  • 1
  • 6

1 Answers1

4

Answering my own questions:

  • path() is meant to be used in plug-in code, not the metalsmith project's index.js.

  • It takes a series of strings, which will be concatenated (with path separators) into a single path, which is then resolved relative to the metalsmith instance's given path.

E.g., from metalsmith-layouts:

var str = metalsmith.path(dir, data.layout || def);

James Harkins
  • 99
  • 1
  • 6