Drupal Content Entity schema generator for Druxt with support for View and Form displays.
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
-
Install the package:
npm i druxt-schema -
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
- For the full class and store reference, see the DruxtSchema API documentation.
Options
Druxt options
These options are available to all Druxt modules.
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
axios | object | No | {} | Axios instance settings. |
baseUrl | string | Yes | null | Base URL for the Drupal installation. |
endpoint | string | No | /jsonapi | JSON:API Endpoint of the Drupal installation. |
Druxt Schema options
These options are specific to this module.
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
schema.filter | array | No | [] | Array of regular expression rules to filter generated schemas. |
Note: The contents of this file were automatically generated from the packages/schema/README.md.