metalsmith-relative

1.0.3 • Public • Published

metalsmith-relative

A 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.

usage

Add the plugin to your build:

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):

script(src=relative('/js/foobar.js'))

Results in:

<script src="../../js/foobar.js" />

options

methodName: Name of the method which will be injected into the metadata. Defaults to relative

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    35
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    35
  • 1.0.2
    0
  • 1.0.1
    0

Package Sidebar

Install

npm i metalsmith-relative

Weekly Downloads

35

Version

1.0.3

License

MIT

Last publish

Collaborators

  • sventschui