Metalsmith middleware to serve files with express
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib Refactor to use more of a singleton pattern. Better logging. Oct 20, 2015
.editorconfig Initial release 0.0.1 Oct 20, 2015
.gitignore
.jshintrc
LICENSE Initial commit Oct 19, 2015
README.md
index.js
package.json Adding in tape / chalk as deps. Bumping version. Oct 20, 2015

README.md

metalsmith-express

express based middleware for metalsmith for local development and testing.

By default, this will use express.static to serve your metalsmith built files. It also uses connect-livereload which works well in conjunction with metalsmith-watch for development purposes.

To disable connect-livereload see options below.

Usage

var metalsmith        = require('metalsmith');
var watch             = require('metalsmith-watch');
var metalsmithExpress = require('metalsmith-express');

metalsmith(__dirname)
  .use(metalsmithExpress())
  .use (
    watch({
      paths: {
        '${source}/**/*': true
      },
      livereload: true
    })
  )
  .build(function(err) {
    if (err) throw err;
  });

Options

{
  "liveReload": true,
  "liveReloadPort": 35729,
  "middleware": []
}

You may use express middleware by pushing it onto the middleware option array. Currently only the use(function(req,res,next)) convention is supported.

var middleware = [];

middleware.push(function(req, res, next) {
  console.log('Time:', Date.now());
  next();  
});

var metalsmithExpress = require('metalsmith-express')
({
  middleware: middleware
});

Todo

  • Tests!
  • Allow for any valid middleware pattern

License

MIT