1.0.1 • Published 7 years ago
metalsmith-cockpit v1.0.1
metalsmith-cockpit
A Metalsmith plugin to retrieve content from the Cockpit API
Installation
npm install --save metalsmith-cockpitOr if you prefer to use Yarn...
yarn add metalsmith-cockpitCLI 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- URL for Cockpit API (e.g. http://localhost/api)
cockpitApiToken- required- Valid API token to
GETthe required resource type / name
- Valid API token to
resourceName- required- The name of the resource in Cockpit (this will be the collection name, singleton name, etc)
resourceType- defaultcollections- 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- defaultresourceName- If you're using the
metalsmith-collectionsplugin you can set the name of the collection entries will be added to via metadata
- If you're using the