Natural Pleistocene Monsters

    @last-rev/contentful-cms-loader
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.0 • Public • Published

    Overview

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

    Usage

    import createLoaders from '@last-rev/contentful-cms-loader';
    
    async function () {
      const {
        entryLoader,
        assetLoader,
        entriesByContentTypeLoader,
        fetchAllPages,
        fetchAllContentTypes
      } = await createLoaders(
        // TODO
      );
    }

    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.

    Keywords

    none

    Install

    npm i @last-rev/contentful-cms-loader

    DownloadsWeekly Downloads

    484

    Version

    0.4.0

    License

    ISC

    Unpacked Size

    38.1 kB

    Total Files

    18

    Last publish

    Collaborators

    • maxtechera.lastrev
    • tharris
    • justinlastrev
    • jaimelastrev
    • bradtaylorsf