metalsmith-cockpit
v1.0.1
Published
A metalsmith plugin to retrieve resources (collections, singletons, etc) from the Cockpit API
Downloads
3
Readme
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- URL for Cockpit API (e.g. http://localhost/api)
cockpitApiToken
- required- Valid API token to
GET
the 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-collections
plugin you can set the name of the collection entries will be added to via metadata
- If you're using the