Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.48 KB

README.md

File metadata and controls

48 lines (33 loc) · 1.48 KB

metalsmith-template-data

Build Status Coverage Status Dependency Status devDependency Status

A Metalsmith plugin to import template data from CommonJS modules. This plugin extends Metalsmith file objects with the contents of any CommonJS modules specified by the dataFile property of the file.

Installation

$ npm install metalsmith-template-data

YAML front matter

To import a CommonJS module as template data, add the dataFile property to your file's YAML front matter:

---
template: base.html
dataFile: data/index.js
---

You data file should export an object.

If any properties of the imported data object conflict with properties you define in your YAML front matter, the values specified in the data file will override those specified in front matter.

JavaScript usage

var templateData = require('metalsmith-template-data');
metalsmith.use(templateData());

CLI usage

{
  "plugins": {
    "metalsmith-template-data": {}
  }
}

License

MIT