0.6.0 • Published 1 month ago

@last-rev/contentful-redis-loader v0.6.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

Overview

This library exports a single default function which creates a set of data loaders and fetchers for loading contentful structured content from a file system.

Requirements

You must have a directory to which Contentful content has been synced. Please see the documentation for LastRev's cms-sync CLI which will generate this structure for you.

The directory should follow the following structure

dir
└── {contentful space id}
    └── { contentful environment name}
        └── { preview|production }
            ├── assets
            |   ├── {assetId}.json
            |   └── ...
            ├── entries
            |   ├── {entryId}.json
            |   └── ...
            ├── entry_ids_by_content_type
            |   ├── {entryId}
            |   └── ...
            └── content_types
                ├── {contentTypeId}.json
                └── ...

Usage

import createLoaders from '@last-rev/contentful-fs-loader';

async function () {
  const {
    entryLoader,
    assetLoader,
    entriesByContentTypeLoader,
    fetchAllContentTypes
  } = await createLoaders(
    './graphql/content' // root directory
    'saasdfgb34r8ffg7rtt', // contentful space ID
    'master', // contentful environment
    'preview' // one of 'preview' or 'production'
  );
}

entryLoader, assetLoader, and entriesByContentTypeLoader are all instances of dataloader. entryLoader and assetLoader are both keyed by contentful ID (string), and entriesByContentTypeLoader is keyed by a Contentful content type ID (string).

const myEntry = await entryLoader('my-content-id-1234');
const myAsset = await assetLoader('my-asset-id-5432');
const myEntries =  await entriesByContentTypeLoader('pageGeneral');

the other two functions, fetchAllPages and fetchAllContent are just convenience functions that return a list of all page content items (entries which have a slug field) and all content types.

0.6.0

1 month ago

0.5.4

12 months ago

0.5.3

1 year ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.3

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago