# @last-rev/adapter-contentful

> Transforms data from contentful's structure to one which is expected by LastRev components

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

## Install

```sh
npm install @last-rev/adapter-contentful
pnpm add @last-rev/adapter-contentful
yarn add @last-rev/adapter-contentful
bun add @last-rev/adapter-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 | 4.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 | 2 |
| Unpacked size | 77.4 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/adapter-contentful
- npm.io page: https://npm.io/package/@last-rev/adapter-contentful

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.19
- [dot-prop](https://npm.io/package/dot-prop.md) 5.2.0

## Recent versions

- 4.3.2-alpha.2 (latest) — 2022-03-10
- 4.3.2-alpha.1 — 2021-06-10
- 4.3.2-alpha.0 — 2021-06-10
- 4.3.1 — 2021-05-18
- 4.3.0 — 2021-05-11
- 4.3.0-alpha.3 — 2021-04-09
- 4.3.0-alpha.1 — 2021-04-08
- 4.3.0-alpha.0 — 2021-04-08
- 4.2.0 — 2021-03-09
- 4.1.2-alpha.1 — 2021-03-09
- 4.1.1 — 2021-03-04
- 4.1.0 — 2021-03-02
- 4.0.0 — 2021-02-26
- 3.0.6-alpha.0 — 2021-02-11
- 3.0.6 — 2021-01-25
- … 21 more at https://npm.io/package/@last-rev/adapter-contentful/versions

## README

# LastRev Contentful Adapter

Converts contentful data shape to one that is expected by LastRev components.

## usage

```javascript
import Adapter from '@last-rev/adapter-contentful';
import config from './adapter-config';
import contentful from './contentfulApi';

const transform = Adapter(config);

export default async () => {
  return transform(contentful.getGlobalSettings());
};
```

## config

Confifg allows one to override specific field names for parsing URLs:

```javascript
// defaults
{
  urlMap = {},
  linkContentType = 'elementLink',
  sameWindowActionText = 'Open in the same window',
  newWindowActionText = 'Open in a new window',
  modalActionText = 'Open in a modal',
  downloadActionText = 'Download',
  manualEntryTypeText = 'Manual text entry',
  contentRefTypeText = 'Content reference',
  assetRefTypeText = 'Asset reference',
  contentUrlLookup = {}
  skipContentTypes = []
}

// example:

{
  "urlMap": {
    "pageGeneral": {
      "url": "/[key]", // alweays use "key" for the slug here
      "key": "slug" // this is what the next.js dynamic routing framework
      // expects the param to be called
    },
    "pageRecipe": {
      "url": "/recipes/[key]",
      "key": "slug"
    }
  },
  "linkContentType": "ElementCta"
}
```

## URL lookup

The preferred method to generate the correct `_href` and `_as` properties for the content items is to pass in a contentUrlLookup property which maps a contentID to an object like this `{ href: '...whatever', as: '...whatever' }`. If this cannot be done, the old urlMap method is still supported.

## skipping types

If for whatever reason we do not want to traverse items of a specific content type, just pass those content type IDs into the `skipContentTypes` array.

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