Skip to content

Drupal Content Entity schema generator for Druxt with support for View and Form displays.

Schema

Drupal Content Entity schema generator for Druxt with support for View and Form displays.

npm CI Known Vulnerabilities codecov

DruxtSchema turns Drupal display configuration into build-time schemas. For each entity type, bundle and display mode it records which fields render, in what order and with which formatter settings, and stores the result in a Vuex store. The Entity module renders from these schemas at runtime, so your frontend follows Drupal's display configuration without querying it on every request.

Features

  • Generates schemas on build
  • Configurable schema filter
  • View and Form schemas

Installation

  1. Install the package:

    npm i druxt-schema
    
  2. Add the module to nuxt.config.js:

    export default {
      modules: ['druxt-schema'],
    };
    

Settings

Filter schemas

The Schema module will generate a schema for all available content entity type by bundle, display mode and schema type.

This generated schemas can be filtered by providing a druxt.schema.filter setting in the nuxt.config.js file:

export default {
  modules: ['druxt-schema'],
  druxt: {
    schema: {
      filter: [
        // List specific schema files to generate.
        'node--page--default--view',
        'media--image--square--view',
        // Or use a regular expression.
        '.*?--form',
      ],
    },
  },
};

API


Options

Druxt options

These options are available to all Druxt modules.

OptionTypeRequiredDefaultDescription
axiosobjectNo{}Axios instance settings.
baseUrlstringYesnullBase URL for the Drupal installation.
endpointstringNo/jsonapiJSON:API Endpoint of the Drupal installation.

Druxt Schema options

These options are specific to this module.

OptionTypeRequiredDefaultDescription
schema.filterarrayNo[]Array of regular expression rules to filter generated schemas.

Note: The contents of this file were automatically generated from the packages/schema/README.md.