1.0.3 • Published 4 years ago

@pienter/gridsome-source-directus v1.0.3

Weekly downloads
78
License
MIT
Repository
github
Last release
4 years ago

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:

NameRequiredTypeDefaultDescription
urltruestring/Directus API root url (see here for more info)
projectfalsestring'_'Directus project prefix
tokenfalsestring''Directus static token (see here for more info), use either token or email/password
emailfalsestring''Directus user email
passwordfalsestring''Directus user password
camelCasefalsebooleantrueTransform field names to camel case
shallowCamelCasefalsebooleanfalseDo only a shalow transformation to camel case. Use this after updating this package
pascalTypesfalsebooleantrueConverts table names to pascal case
routesfalseobject{}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',
        },
      },
    },
  ],
};
1.0.3

4 years ago

1.0.2

5 years ago

1.0.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago