docpad-plugin-functions

2.0.2 • Public • Published

docpad-plugin-functions

Travis CI Build Status NPM version NPM downloads Dependency Status Dev Dependency Status
Slack community badge Patreon donate button Gratipay donate button Flattr donate button PayPal donate button Bitcoin donate button Wishlist browse button

Start functions between DocPad events

Install

Install this DocPad plugin by entering docpad install functions into your terminal.

Usage

This plugin was inspired by docpad-plugin-gulp and behaviour of this plugin is almost the same code-wise and in implementation BUT with slight differences:

  • you don't need gulp to run it
  • MAJOR: it's not spawning any child processes so it is 100% compliant with Windows/Unix.

AVAILABLE EVENTS

(not available renderDocument, and render since they caused memory spikes and shouldn't be used in this plugin)

Docpad.coffee structure

The following will run function validateDocuments during the generateBefore event:

validateDocuments = require 'validator.js' #this require should be at the top of docpad.coffee 
 
  plugins:
    functions:
      generateBefore: [validateDocuments]
      writeAfter: [asyncFunction1someOtherAsyncFunction2]

asyncFunction1 and someOtherAsyncFunction2 will be run in series

Function structure

Every passed function should have following structure with callback:

validator.js

function validateDocuments(cb) {
 
  checkFilesAsynchronously((err) => {
    cb(err);
  });
}

TO DO

  • support for sync calls
  • mechanism for easy passing arguments to functions

To be implemented if there is someone to actually use it, so feel free to file issues

History

Discover the release history by heading on over to the releases page.

Contribute

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Patreon donate button Gratipay donate button Flattr donate button PayPal donate button Bitcoin donate button Wishlist browse button

Contributors

These amazing people have contributed code to this project:

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

License

Unless stated otherwise all works are:

and licensed under:

Package Sidebar

Install

npm i docpad-plugin-functions

Weekly Downloads

1

Version

2.0.2

License

MIT

Last publish

Collaborators

  • sdomagala