4.3.2-alpha.2 • Published 2 years ago

@last-rev/adapter-contentful v4.3.2-alpha.2

Weekly downloads
433
License
ISC
Repository
-
Last release
2 years ago

LastRev Contentful Adapter

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

usage

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:

// 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.

4.3.2-alpha.2

2 years ago

4.3.2-alpha.1

3 years ago

4.3.2-alpha.0

3 years ago

4.3.1

3 years ago

4.3.0

3 years ago

4.3.0-alpha.3

3 years ago

4.3.0-alpha.1

3 years ago

4.3.0-alpha.0

3 years ago

4.1.2-alpha.1

3 years ago

4.2.0

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.0

3 years ago

3.0.6-alpha.0

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.2

3 years ago

3.0.2-alpha.8

4 years ago

3.0.2-alpha.7

4 years ago

3.0.2-alpha.6

4 years ago

3.0.2-alpha.5

4 years ago

3.0.2-alpha.4

4 years ago

3.0.2-alpha.2

4 years ago

3.0.2-alpha.1

4 years ago

3.0.2-alpha.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago