0.1.15 • Published 4 years ago

@autolist/contentful v0.1.15

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

Contentful Client

Test Coverage Maintainability

Installation

Using npm:

$ npm i --save @autolist/contentful

Using yarn:

$ yarn add @autolist/contentful

Usage:

import { Item, Params } from '@autolist/contentful`
import { createClient } from 'contentful'

class Article extends Item {
}

// You must register all classes with the parent class if you
// want to override behavior for specific content types,
// so that we can look them up later for association parsing.
// Otherwise, the default Item class will be used.
Item.classes['article'] = Article

class ArticleParams extends Params {
  static fields = ['slug']
}

const params = new ArticleParams({
  // Fields will be inferred and translated to contentful params
  slug: 'our-slug',
  // Skip is inferred from a combination of page and limit
  page: 2,
  limit: 10,
  // 'en' locale is assumed to be shorthand for 'en-US'
  locale: 'en',
  // Relationship queries are too variable to reliably
  // infer, so pass them in by hand
  'fields.parentPage.sys.contentType.sys.id': 'page',
  'fields.parentPage.fields.slug': 'news-and-analysis'
}, Article)

const client = createClient(myCredentials)

const contentfulResponse = await client.getEntries(paramsObject.toJSON())

const [article] = Article.load(contentfulResponse)

console.log(article.toJSON())

:hammer_and_wrench: Development

Install dependencies:

yarn

:robot: Testing

yarn:

yarn test

Building

yarn:

yarn build

Releasing

  1. Bump version in package.json
  2. npm publish (Use npm and 2FA to publish until https://github.com/yarnpkg/yarn/issues/4904 is resolved)
0.1.15

4 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.0.1

6 years ago