Skip to content

An npm module with helper functions for javascript-based prismic.io static-sites

License

Notifications You must be signed in to change notification settings

theruther4d/prismic-static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

An npm module with helper functions for javascript-based prismic.io static-sites

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published