metalsmith-hierarchy

0.1.0 • Public • Published

metalsmith-hierarchy

Metalsmith plugin that adds hierarchy information to file metadata. Uses file metadata parent property to crawl until a file with no parent is found, the list is output to the hierarchy property with the root node first and the current node last.

Advice / Rant

It's a bit laborous to add parent properties to a large amount of pages (something like blog posts), a plugin like metalsmith-filemetadata, for batch editing metadata is prefered over weird plugin only logic inside of this plguin.

When using this plugin, beware that the hierarchy property is inherently cyclical so be careful while using plugins that serializes file metadata like metalsmith-writemetadata.

Installation

$ npm install metalsmith-hierarchy --save-dev

Javascript Usage

Pass to `Metalsmith#use.

var hierarchy = require('metalsmith-hierarchy');
 
metalsmith.use(hierarchy());

Example

archive.html

---
slug: archive
---

post.html

---
slug: post
parent: archive.html
---

Output

post-output.html

---
slug: post
parent: archive.html
hierarchy: [
  { archive.html metadata },
  { post.html metadata },
]
---

Options

There currently no options, any suggestions or pull-requests will be considered.

License

MIT 2015

Package Sidebar

Install

npm i metalsmith-hierarchy

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • krambuhl