npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tinacms-contentful

v0.7.15

Published

TinaCMS API Client, Media Client, and utilities for the Contentful APIs

Downloads

27

Readme

tinacms-contentful

A library for using Contentful with TinaCMS

Usage

Installation

To install the package, run:

npm install tinacms-contentful contentful contentful-management

Setup

To setup TinaCMS with Contentful, you must create an instance of the TinaCMS ContentfulClient for each space you want to edit content from.

For a single space:

import { ContentfulClient } from 'tinacms-contentful'

const contentful = new ContentfulClient({
  spaceId: /* Contentful Space ID */,
  defaultEnvironmentId: /* Contentful environment ID to use by default. Default: master */,
  accessTokens: {
    delivery: /* Contentful delivery access token for the space */,
    preview: /* Contentful preview access token for the space */,
  }
  clientId: /* OAuth App Client ID */,
  redirectUrl: /* OAuth App Callback URL */,
  rateLimit: /* API Rate Limit for your Contentful Plan (Requests per second). Default: 4 */,
  insecure: /* If true, uses same-site HTTPS cookies to create a session. Default: false */
})

const cms = new TinaCMS({
  apis: {
    contentful
  }
})

Or if the CMS has already been created:

cms.registerApi('contentful', contentful)

For multiple spaces:

import { createContentfulClientForSpaces } from 'tinacms-contentful';

const spaces = [
  {
    spaceId: /* Contentful Space ID */,
    defaultEnvironmentId: /* Contentful environment ID to use by default. Default: master */,
    accessTokens: {
      delivery: /* Contentful delivery access token for the space */,
      preview: /* Contentful preview access token for the space */,
    }
  },
  {
    spaceId: /* Contentful Space ID */,
    defaultEnvironmentId: /* Contentful environment ID to use by default. Default: master */,
    accessTokens: {
      delivery: /* Contentful delivery access token for the space */,
      preview: /* Contentful preview access token for the space */,
    }
  }
]

const contentful = createClientForSpaces(spaces, {
  clientId: /* OAuth App Client ID */,
  redirectUrl: /* OAuth App Callback URL */,
  rateLimit: /* API Rate Limit for your Contentful Plan (Requests per second). Default: 4 */,
  insecure: /* If true, uses same-site HTTPS cookies to create a session. Default: false */
})

Media

To add support for media, you must setup a media store for the space media should be uploaded to.

For a single space:

import { ContentfulClient, ContentfulMediaStore } from 'tinacms-contentful'

const contentful = new ContentfulClient({
  spaceId: /* Contentful Space ID */,
  defaultEnvironmentId: /* Contentful environment ID to use by default. Default: master */,
  accessTokens: {
    delivery: /* Contentful delivery access token for the space */,
    preview: /* Contentful preview access token for the space */,
  }
  clientId: /* OAuth App Client ID */,
  redirectUrl: /* OAuth App Callback URL */,
  rateLimit: /* API Rate Limit for your Contentful Plan (Requests per second). Default: 4 */,
  insecure: /* If true, uses same-site HTTPS cookies to create a session. Default: false */
})

const contentfulMediaStore = new ContentfulMediaStore(contentful);

const cms = new TinaCMS({
  apis: {
    contentful
  },
  media: contentfulMediaStore
})

For multiple spaces:

The media store is only capable of acting on a single space at a time. To change spaces dynamically, run:

const spaceId = 'example-id'
const space = cms.api.contentful[spaceId]
cms.media.store = new ContentfulMediaStore(space)

APIs

The library has the following core APIs:

There are other public APIs as well. To learn more, read the full API documentation.

Contentful Client

Creates a TinaCMS API client for communicating with a Contentful Space.

Options

The client takes the following constructor arguments.

Properties

The Client has the following properties:

  • allowedOrigins: the FQDNs allowed to receive Oauth bearer tokens. Defaults to the window hostname.
  • environment: the current Contentful environment the space is communicating with.
  • rateLimit: the rate limit at which API operation will be throttled to.
  • sdks: the Contentful SDK Client instances for this space.

Methods

The Client has the following methods:

  • authenticate: triggers a popup window OAuth workflow .
  • setEnvironment: changes the environment the space is communicating with.
  • getEntry: fetch a published delivery, draft preview, or editable management entry.
  • getEntries: fetch multiple published delivery, draft preview, or editable management entries.
  • createEntry: create a new entry for a specific content model.
  • updateEntry: update an existing entry with new data.
  • deleteEntry: delete a specific entry.
  • publishEntry: publish a specific entry.
  • unpublishEntry: unpublish a specific entry.
  • archiveEntry: archive a specific entry.
  • getAsset: fetch a published delivery, or draft preview asset.
  • getAssets: fetch multiple published delivery, or draft preview assets.
  • getAssetCollection: fetch a paginated collection of published delivery, or draft preview assets.
  • createAsset: create a new asset from a file upload.
  • updateAsset: update an existing asset from a file upload.
  • deleteAsset: delete a specific asset.
  • archiveAsset: archive a specific asset.
  • getContentType: fetch a specific content type.
  • sync: [EXPERIMENTAL] Fetch all entries and assets from the space in the given environment to allow access without network connection.