An npm module with helpers for using prismic.io javascript API with javascript-based static-site generators.
npm install prismic-static
var PrismicStatic = require( 'prismic-static' );
var myPrismic = new PrismicStatic( '<YOUR_API_KEY_HERE>' );
var collections = myPrismic.getAllDocuments( function( docs ) {
...
});
Fetches all document from a repository given the API key
Arguments
- callback (function) - the callback function to be executed when the fetch has been completed.
Returns
- ( object ) - with keys
collections
andtags
. Each of the values is itself an object containing keys for each respectivecollection
andtag
type. The value of each of these keys is an array of prismic documents. Ex:
{
collections: {
posts: [documents],
pages: [documents],
projects: [documents]
},
tags: {
design: [documents],
development: [documents],
css: [documents]
}
}
Fetches all documents of a specified type from the repository.
Arguments
- type ( string ) - the custom-type name that you'd like to fetch.
- callback ( function ) - the callback function to be executed when the fetch has been completed.
Returns
- ( object ) - with keys for document type and corresponding values as an array of prismic documents. Ex:
{
posts: [documents],
pages: [documents],
projects: [documents]
}
Fetches all tagged documents for a specified type and sorts by tag name.
Arguments
- type ( string ) - the custom-type name that you'd like to fetch.
- callback ( function ) - the callback function to be executed when the fetch has been completed.
Returns
- ( object ) - with keys for each tag name and corresponding values as an array of prismic documents. Ex:
{
design: [documents],
development: [documents],
css: [documents]
}