0.1.0 • Published 9 years ago
metalsmith-filedata v0.1.0
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-filedataUsage
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
0.1.0
9 years ago