Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

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

3

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability