Metalsmith JSTransformer Plugin
Metalsmith plugin to process files with any JSTransformer.
Installation
npm install --save metalsmith-jstransformer
CLI
If you are using the command-line version of Metalsmith, you can install via npm, and then add the metalsmith-jstransformer
key to your metalsmith.json
file:
{
"plugins": {
"metalsmith-jstransformer": {}
}
}
JavaScript
If you are using the JS Api for Metalsmith, then you can require the module and add it to your .use()
directives:
var jstransformer = require('metalsmith-jstransformer');
metalsmith.use(jstransformer());
Usage
Create files that you would like to act on with JSTransformers with file extensions representing the transformer to use, in the format example.html.<transformer>
. For example, if you would like to process with Jade, you would name it example.html.jade
.
Use multiple transformers by appending additional file extension transformer names at the end. For example, to HTML-Minifier our Jade example above, you would use the filename example.html.html-minifier.jade
.
Example
The following example uses Jade, so we must additionally install jstransformer-jade
:
npm install jstransformer-jade --save
src/example.html.jade
---
pageTitle: My Site
pretty: true
---
doctype html
html(lang="en")
head
title= pageTitle
body
p This is my site!
Result
<!doctype html>
<html>
<head>
<title>My Site</title>
</head>
<body>
<p>This is my site!</p>
</body>
</html>
License
MIT