1.0.0 • Published 10 years ago
metalsmith-pooleapp v1.0.0
metalsmith-pooleapp
A Metalsmith plugin to retrieve data stored in http://pooleapp.com/. PooleApp is a hosted data store dedicated to static website. Amongst others things, it can be used to store comments.
Installation
$ npm install metalsmith-pooleappJavaScript usage
var pooleApp = require('metalsmith-pooleapp');
metalsmith.use(pooleApp({
"forms": {
"comments": {
"secret": "theSecretKeyFromPooleApp",
"identifier": "path",
"filter": "foor == 2 or bar < 20"
},
}
});The function exported by the metalsmith-pooleapp expects an object in
parameter with a forms property. This property contains an object with an
arbitrary number of sub-objects. Each one describing a PooleApp form and how
the data will be available in Metalsmith:
- the key (
commentsin this example) is used to register the data in the Metalsmith's metadata. Here, the collected data are available with:metalsmith.metadata().pooleapp.comments. Ifidentifieris filled (see below), this identifier is also used to register the collected data under the file. - the
secretis necessary to build the URL to fetch the data from PooleApp.com - the
identifieris optional, it holds a property name. The plugin compares the value of this property in the file object and in the remote object and if they match, the remote object is added to the array available under the key (commentshere) - the
filteris optional, it allows to filter the PooleApp entries. It uses the filtrex expression engine.
If you use the metalsmith-permalink plugin, the identifier can set to path.
By doing that and by adding the path in an hidden form field, the collected
data are directly available in the file object where the form was filled.
CLI usage
{
"plugins": {
"metalsmith-pooleapp": {
"forms": {
"comments": {
"secret": "theSecretKeyFromPooleApp",
"identifier": "path",
"filter": "foor == 2 or bar < 20"
}
}
}
}
}License
MIT