2.2.1 • Published 1 year ago

gatsby-source-directus9 v2.2.1

Weekly downloads
-
License
0BSD
Repository
github
Last release
1 year ago

gatsby-source-directus9

Source plugin for pulling content, and assets into Gatsby from Directus CMS.

NOTE: This source plugin requires custom directus extensions to function properly which are still in development

Install

npm install gatsby-source-directus9

How to use

First, you need a way to pass environment variables to the build process, so secrets and other secured data aren't committed to source control. We recommend using dotenv which will then expose environment variables. Read more about dotenv and using environment variables here. Then we can use these environment variables and configure our plugin.

Restrictions and limitations

This plugin has several limitations, please be aware of these:

  1. All sync content requires a updated date field which can be set in the plugin options. Make sure this value is updated even on create.

  2. References are only attached to content that have a valid relationship. e.g a M2M from A <-> B, which was created from A, there will be a reference from A to B but no reverse from B to A. You will need to also create a field on B.

  3. Syncing works from the current env you are running, called from os.userInfo(), This is used to remember the difference from the last sync from your environment.

Usage

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-directus9`,
      options: {
        host: `directus.example.com`,
        // Learn about environment variables: https://gatsby.dev/env-vars
        accessToken: process.env.DIRECTUS_ACCESS_TOKEN,
      },
    },
  ],
}

Configuration options

accessToken string

Directus Access Token, generated on a user with read permissions to content being request.

host string

The host for the directus instance. e.g directus.example.com

useSSL boolean default: true

Send api calls using https vs http. Usefull for connecting to a local instance of directus.

updatedAtKey string default: date_updated

The key for the field which saves the date updated on every piece of content. Only requried when not using directus system default date_updated field.

envId string

Set a manual dev-env for the directus sync process. This allows to share the sync status between different environments. if NODE_ENV=development defaults to os.userInfo() data.

downloadLocal boolean default: false

Downloads and caches DirectusAssets's to the local filesystem. Allows you to query a DirectusAssets's localFile field

pageLimit number default: 100

Number of entries to retrieve from Directus at a time. If you run into payload size limit issues, try to reduce this number to e.g 50

assetDownloadWorkers number default: 50

Number of workers to use when downloading Directus assets. Due to technical limitations, opening too many concurrent requests can cause stalled downloads. If you encounter this issue you can set this param to a lower number than 50, e.g 25.

2.1.0-next.2

1 year ago

2.1.0-next.3

1 year ago

2.2.0-next.1

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

1.2.0

2 years ago

2.1.0-next.1

2 years ago

1.2.1

2 years ago

2.0.0-next.2

2 years ago

2.0.0-next.1

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago