# @last-rev/integration-contentful

> Contentful integration for lastrev projects

Latest version **5.3.2-alpha.2** (published 2022-03-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install @last-rev/integration-contentful
pnpm add @last-rev/integration-contentful
yarn add @last-rev/integration-contentful
bun add @last-rev/integration-contentful
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.3.2-alpha.2 |
| Published | 2022-03-10 |
| First published | 2020-07-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 85.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jaime Morales |
| Maintainers | maxtechera.lastrev, tharris, justinlastrev, jaimelastrev, bradtaylorsf |

## Links

- npm: https://www.npmjs.com/package/@last-rev/integration-contentful
- npm.io page: https://npm.io/package/@last-rev/integration-contentful

## Dependencies (6)

- [lodash](https://npm.io/package/lodash.md) ^4.17.19
- [deepdash](https://npm.io/package/deepdash.md) ^5.3.5
- [contentful](https://npm.io/package/contentful.md) ^8.1.7
- [@types/faker](https://npm.io/package/@types/faker.md) ^4.1.12
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.10.4
- [@last-rev/adapter-contentful](https://npm.io/package/@last-rev/adapter-contentful.md) ^4.3.2-alpha.2

## Recent versions

- 5.3.2-alpha.2 (latest) — 2022-03-10
- 5.3.2-alpha.1 — 2021-06-10
- 5.3.2-alpha.0 — 2021-06-10
- 5.3.1 — 2021-05-18
- 5.3.0 — 2021-05-11
- 5.2.2 — 2021-05-05
- 5.3.0-alpha.19 — 2021-04-23
- 5.3.0-alpha.18 — 2021-04-09
- 5.3.0-alpha.17 — 2021-04-09
- 5.3.0-alpha.16 — 2021-04-09
- 5.3.0-alpha.15 — 2021-04-09
- 5.3.0-alpha.14 — 2021-04-09
- 5.3.0-alpha.12 — 2021-04-09
- 5.3.0-alpha.11 — 2021-04-08
- 5.3.0-alpha.10 — 2021-04-08
- … 59 more at https://npm.io/package/@last-rev/integration-contentful/versions

## README

# LastRev Contentful Integration

This module provides a set of useful funtions for querying data from Contentful, and adapting that data to LastRev structured websites.

## Environment variables

This module expects the following environment variables:

- `CONTENTFUL_SPACE_ID` = The spaceId from contentful
- `CONTENTFUL_ENV` - Contentful environment
- `CONTENTFUL_ACCESSTOKEN` - Contentful API access token
- `CONTENTFUL_HOST` - Contentful Host
- `CONTENTFUL_SETTINGS_ID` - The ID of the `settingsGlobal` content item to use

## usage

The module can be used one of two ways. First you can call the methods directly, which will give you the raw Contentful data:

```javascript
import { getPageBySlug } from '@last-rev/integration-contentful';

getPageBySlug(id, contentType).then((raw) => {
  console.log(raw);
  /*
  {
    sys: {
      id: '1234',
      contentType: {
        sys: {
          id: 'moduleCardGeneral'
        }
      }
    },
    fields: {
      title: 'My Title',
      image: ...
    }
  }
  */
});
```

The other way to use it is to initialise the default export with a configuration for the `@last-rev/adapter/contentful` [adapter](https://github.com/last-rev-llc/lastrev-adapter-contentful). The resulting functions will then be adapted to the shape expected by LastRev components:

```javascript
import Contentful from '@last-rev/integration-contentful';

const urlMap = {
  pageGeneral: {
    url: '/[key]',
    key: 'slug'
  },
  pageBlog: {
    url: '/[key]',
    key: 'blogId'
  }
};

const linkContentType = 'ctaLink';

const { getPageBySlug } = Contentful({ urlMap, linkContentType });

getPageBySlug(id, contentType).then((clean) => {
  console.log(clean);
  /*
  {
    id: '1234',
    contentTypeId: 'moduleCardGeneral',
    title: 'My Title',
    image: ...
  }
  */
});
```

## Documentation

Official documentation can be found [here](https://last-rev-llc.github.io/lastrev-integration-contentful/index.html).

---
_Source: https://npm.io/package/@last-rev/integration-contentful · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
