metalsmith-cockpit

1.0.1 • Public • Published

metalsmith-cockpit

A Metalsmith plugin to retrieve content from the Cockpit API

Installation

npm install --save metalsmith-cockpit

Or if you prefer to use Yarn...

yarn add metalsmith-cockpit

CLI Usage

{
    "plugins": {
        "metalsmith-cockpit": {
            "resourceType": "collections",
            "resourceName": "posts",
            "resourceFilter: { "published": true },
            "destination": "./articles"
        }
    }
}

JavaScript Usage

const metalsmith = require('metalsmith')
const cockpit = require('metalsmith-cockpit')

metalsmith.use(cockpit({
    cockpitApiUrl: process.env.COCKPIT_API_URL,
    cockpitApiToken: process.env.COCKPIT_API_TOKEN,
    resourceType: 'collections',
    resourceName: 'posts',
    resourceFilter: { published: true },
    destination: './articles'
}))

Available Options

  • cockpitApiUrl - required
  • cockpitApiToken - required
    • Valid API token to GET the required resource type / name
  • resourceName - required
    • The name of the resource in Cockpit (this will be the collection name, singleton name, etc)
  • resourceType - default collections
    • The type of resource we're retrieving - must be a valid type within Cockpit (collections, forms, singletons)
  • resourceFilter - default {}
    • A hash of filters that will be included in the request to the Cockpit API (e.g. `{ published: true })
  • destination - default ./
    • The directory the entries will be output into
  • collection - default resourceName
    • If you're using the metalsmith-collections plugin you can set the name of the collection entries will be added to via metadata

Readme

Keywords

none

Package Sidebar

Install

npm i metalsmith-cockpit

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

68.8 kB

Total Files

48

Last publish

Collaborators

  • eatthebytes