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

gatsby-source-directus9

v2.2.1

Published

Source data from directus v9.0.0 cms

Downloads

241

Readme

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][required]

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

host [string][required]

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

useSSL [boolean][optional] [default: true]

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

updatedAtKey [string][optional] [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][optional]

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][optional] [default: false]

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

pageLimit [number][optional] [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][optional] [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.