Miss any of our Open RFC calls?Watch the recordings here! »

metalsmith-filedata

0.1.0 • Public • Published

metalsmith-filedata

Add file, CSS for example, content to global metadata. An example of a use case would be using Sass and having a critical CSS .scss output that needs to be in available inline in markup.

Installation

npm install metalsmith-filedata

Usage

var filedata = require('metalsmith-filedata')
 
Metalsmith(__dirname)
  .use(filedata(options))
  .build()

Options

  • pattern: String|Array<String>
  • key: String

Example

Metalsmith(__dirname)
  .use(filedata({
    pattern: ['styles/*.css', 'scripts/*.js'],
    key: 'contentData'
  }))
  .use(template({ engine: 'handlebars' }))
  .build()

The options.key or filedata object is accessible from Handlebars:

<style>
{{{contentData.[styles/main.css]}}}
</style> 

The compiled markup:

<style>
  body {
    background-color: white;
  }
</style> 

License

The MIT License (MIT)

Install

npm i metalsmith-filedata

DownloadsWeekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • avatar