prismic-static

0.0.2 • Public • Published

Prismic static

An npm module with helpers for using prismic.io javascript API with javascript-based static-site generators.

Install

npm install prismic-static

Usage

var PrismicStatic = require( 'prismic-static' );

var myPrismic = new PrismicStatic( '<YOUR_API_KEY_HERE>' );

var collections = myPrismic.getAllDocuments( function( docs ) {
    ...
});

Helpers

getAllDocuments( callback )

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 and tags. Each of the values is itself an object containing keys for each respective collection and tag 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]
        }
    }

getDocumentsByType( type, callback )

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

getTaggedDocuments( type, callback )

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

Readme

Keywords

none

Package Sidebar

Install

npm i prismic-static

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • the_ruther4d