4.0.6 ā€¢ Published 10 months ago

metalsmith-paths v4.0.6

Weekly downloads
167
License
MIT
Repository
github
Last release
10 months ago

Metalsmith Paths

A Metalsmith plugin that adds file path values (base, dir, ext, name, href) to metadata path property.

license release semantic

Install

npm install metalsmith-paths

API

const metalsmith = new Metalsmith(__dirname)
  .use(paths({
    property: "paths"
  }))

given the following directory structure:

src/
ā””ā”€ā”€ blog
    ā””ā”€ā”€ post.html

The following metadata will be generated:

metadatavalue
path.basepost.html
path.dirblog
path.ext.html
path.namepost
path.href/blog/post.html
path.dhref/blog/

CLI

You can also use the plugin with the Metalsmith CLI by adding a key to your metalsmith.json file:

{
  "plugins": {
    "metalsmith-paths": {
      "property": "paths"
    }
  }
}

Options

namedescriptiondefault
propertyproperty to store the path data topath
directoryIndexremove the filename if it matchesdisabled
winToUnixexchange \ for / on Windows | true

directoryIndex

Removes the filename from the href attribute if it matches the value of directoryIndex. Default: disabled. For example, the following configuration:

{
  "plugins": {
    "metalsmith-paths": {
      "property": "path",
      "directoryIndex": "index.html"
    }
  }
}

Would produce the following filenames:

Filenamepath.href
/index.html/
/portfolio/index.html/portfolio/
/portfolio/project1.html/portfolio/project1.html
/portfolio/project2.html/portfolio/project2.html

Author: Ahmad NassriĀ ā€¢ Twitter: @AhmadNassri