0.3.8 • Published 7 years ago

prismic-scout v0.3.8

Weekly downloads
32
License
MIT
Repository
github
Last release
7 years ago

PrismicScout

npm version

This package extract data from Prismic Query Results using a JSON like GraphQL style

Install

npm install prismic-scout --save

or

yarn add prismic-scout

Documentation

Instance

restriveFromData(
    Object <api>,
    Object <options> 
)

example

const PrismicScout = require('prismic-scout');
...
/*
 * Get Prismic api now we can use `api` variable
 */
...
const Scout = new PrismicScout(api);

Methods

retriveFromData

For array of documents

restriveFromData(
    Array <results>,
    Object <fileds>,
    Object <options>
)

example

/*
 * Inside a Prismic `query` then function
 */
Scout.retriveFromData(results, {
    "title": {
        "_type": "text"
    },
    "description": {
        "_type": "html"
    },
    "image": {
        "url": {}
    }
})

retriveSingle

For single of document

restriveFromData(
    Object <doc>,
    Object <fileds>,
    Object <options>
)

example

/*
 * Inside a Prismic `getByID` then function
 */
Scout.retriveSingle(doc, {
    "title": {
        "_type": "text"
    },
    "description": {
        "_type": "richtext"
    },
    "image": {
        "url": {}
    }
})

Options

clean (default: true)

Extract from document data field and append 'id','uid' and 'lang';

id (default: true)

Append id value to object (without id Scout cannot retrive nested document)

uid (default: true)

Append uid value to object

lang (default: true)

Append lang value to object

example

    /* Set global options */
    const Scout = new PrismicScout(api, {uid: false, lang: false});

    /* Set single options (merged with global options) */
    Scout.retriveFromData(results, {
        "title": {
            "_type": 'html'
        }
    },{
        lang: true // { uid: false, lang: true }
    });

License

This project is under MIT license, 2017, ⓒ Antonio Dal Sie. Read more in LICENSE.

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.2.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago