Skip to content

pienter-tech/gridsome-source-directus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gridsome-source-directus

npm version

I created this script for personal use before peXed published his gridsome-source-directus. Because it has a slightly different approach I decided to publish this package anyway.

Changes

  • Release 1.0.1
    • Renamed addContentType to addCollection for compatibility. If you use a pre 0.7.* version of gridsome use 1.0.0
  • Release 1.0.0
    • Automaticaly converts table names to Pascal Case, this results in a cleaner schema. But all your queries will break after updating. Set pascalTypes to false if you do not want this.
    • Now also converts nested objects to camel case. This can also break your queries. Set shallowCamelCase to true if you do not want this.

Features

  • Automatically gets all collections.
  • Automatically adds references for files.
  • Automatically adds references for relations.
  • Optionally set up routes,
  • Optionally make all field names camel case,

Install

  • yarn add @pienter/gridsome-source-directus
  • npm install @pienter/gridsome-source-directus

Usage

Add the plugin to your gridsome.config.js file.

Options:

Name Required Type Default Description
url true string / Directus API root url (see here for more info)
project false string '_' Directus project prefix
token false string '' Directus static token (see here for more info), use either token or email/password
email false string '' Directus user email
password false string '' Directus user password
camelCase false boolean true Transform field names to camel case
shallowCamelCase false boolean false Do only a shalow transformation to camel case. Use this after updating this package
pascalTypes false boolean true Converts table names to pascal case
routes false object {} Add route option to content type, object where key is the collection and the value is the route (see here for more info)

Example config:

module.exports = {
  plugins: [
    {
      use: '@pienter/gridsome-source-directus',
      options: {
        url: 'https://directus.api.url',
        project: '_',
        email: 'directus@user.something',
        password: 'USERPASSWORD',
        camelCase: false,
        routes: {
          posts: 'posts/:year/:slug',
        },
      },
    },
  ],
};

About

Directus source for Gridsome

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors