Metalsmith plugin to get relative paths
npm install metalsmith-relativeA metalsmith plugin which adds a function to the metadata to calculate relative paths.
This is useful when you can't use absolute paths because you deploy to different context roots.
Add the plugin to your build:
``javascript
var relative = require('metalsmith-relative');
var opts = {
methodName: 'relative'
}; // see options for further information
metalsmith.use(relative({ opts }));
`
Use it within your templates (for example within /foo/bar/baz.jade):
`jade`
script(src=relative('/js/foobar.js'))
Results in:
`html`
methodName: Name of the method which will be injected into the metadata. Defaults to relative`