Skip to content
druxt-entity

Entity

Drupal Display Mode powered Entity, Form and Field Druxt components.

DruxtEntity

npm CI Known Vulnerabilities codecov

Drupal Display Mode powered Entity, Form and Field Druxt components.

Install

$ npm install druxt-entity

Nuxt.js

Add module to nuxt.config.js

module.exports = {
  modules: ['druxt-entity'],
  druxt: {
    baseUrl: 'https://demo-api.druxtjs.org',
    entity: {
      query: {
        schema: true,
        fields: ['path', 'title'],
      },
    },
  },
};

Usage

DruxtEntity component

The DruxtEntity component renders content entities using Drupal's View display modes.

<DruxtEntity :type="resourceType" :uuid="uuid" :mode="displayMode" />

Example DruxtEntity component

See the DruxtEntity API Documentation for more information.

DruxtEntityForm component

The DruxtEntityForm component uses Drupal's Form displays modes for content creation and editing.

<DruxtEntityForm :type="resourceType" :mode="displayMode" />

Example DruxtEntityForm component

See the DruxtEntityForm API Documentation for more information.

Theming

Both components can be themed by providing a default template:

<DruxtEntity type="node--page" :uuid="uuid">
  <template #default="{ entity, fields, schema }">
    {{ entity }}
  </template>
</DruxtEntity>

The module also provides Wrapper components with scoped slots for theming:

<template>
  <div>
    <h1>{{ $attrs.entity.attributes.title }}</h1>
    <slot name="body" />
  <div>
</template>

See the Druxt Theming guide for more information.

Options

Druxt Entity options

These options are specific to this module.

OptionTypeRequiredDefaultDescription
entity.components.fieldsbooleanNofalseWhether to import deprecated default Field components.
entity.query.fieldsstring[]No[]An array of fields to filter all Entity JSON:API queries.
entity.query.schemabooleanNofalseWhether to automatically filter fields based on Display schema.

Base Druxt options

These options are available to all Druxt modules.

OptionTypeRequiredDefaultDescription
axiosobjectNo{}Axios instance settings.
baseUrlstringYesnullBase URL for the Drupal installation.

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