Skip to content

Latest commit

 

History

History
105 lines (80 loc) · 3.24 KB

README.md

File metadata and controls

105 lines (80 loc) · 3.24 KB

Metalsmith Request version License

Metalsmith plugin to grab content from the web and expose the results to metadata.

uses got under the hood to make HTTP calls.

Build Status Downloads Code Climate Coverage Status Dependency Status Dependencies

Install

npm install --production --save metalsmith-request

Usage

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')

API

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
    }
  ))

CLI

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