Metalsmith plugin to grab content from the web and expose the results to metadata.
uses got under the hood to make HTTP calls.
npm install --production --save metalsmith-request
I recommend using an optimized build matching your Node.js environment version, otherwise, the standard require
would work just fine with any version of Node >= v4.0
.
/*
* Node 7
*/
const request = require('metalsmith-request/lib/node7')
/*
* Node 6
*/
const request = require('metalsmith-request/lib/node6')
/*
* Node 4 (Default)
* Note: additional ES2015 polyfills may be required
*/
var request = require('metalsmith-request')
Pass targets
to the plugin with the use
method:
const metalsmith = new Metalsmith(__dirname)
.use(request({
foo: 'http://domain.com/foo'
}))
You can also pass options
as the second argument to use with the got module
const metalsmith = new Metalsmith(__dirname)
.use(request(
{
foo: 'http://domain.com/foo.json'
},
{
json: true
}
))
You can also use the plugin with the Metalsmith CLI by adding a key to your metalsmith.json
file:
{
"plugins": {
"metalsmith-request": {
"foo": "http://domain.com/foo.json"
}
}
}
©️ ahmadnassri.com · License: ISC · Github: @ahmadnassri · Twitter: @ahmadnassri