https://github.com/exodusanto/prismic-scout
Extract data from Prisimic Query Results using a JSON like GraphQL style
https://github.com/exodusanto/prismic-scout
prismic scout scouting
Last synced: 4 months ago
JSON representation
Extract data from Prisimic Query Results using a JSON like GraphQL style
- Host: GitHub
- URL: https://github.com/exodusanto/prismic-scout
- Owner: exodusanto
- License: mit
- Created: 2017-09-11T15:36:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-27T10:06:51.000Z (over 7 years ago)
- Last Synced: 2025-10-26T21:33:23.660Z (7 months ago)
- Topics: prismic, scout, scouting
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PrismicScout
[](http://badge.fury.io/js/prismic-scout)
This package extract data from Prismic Query Results using a JSON like GraphQL style
## Install
```bash
npm install prismic-scout --save
```
or
```bash
yarn add prismic-scout
```
## Documentation
### Instance
```js
restriveFromData(
Object ,
Object
)
```
#### example
```js
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
```js
restriveFromData(
Array ,
Object ,
Object
)
```
#### example
```js
/*
* Inside a Prismic `query` then function
*/
Scout.retriveFromData(results, {
"title": {
"_type": "text"
},
"description": {
"_type": "html"
},
"image": {
"url": {}
}
})
```
### retriveSingle
For single of document
```js
restriveFromData(
Object ,
Object ,
Object
)
```
#### example
```js
/*
* 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
```js
/* 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.