Skip to content
druxt-menu

Menu

Drupal Menu and Menu item Druxt components, with support for the JSON:API Menu Items module.

DruxtMenu

npm CI Known Vulnerabilities codecov

Drupal Menu and Menu item Druxt components, with support for the JSON:API Menu Items module.

Install

$ npm install druxt-menu

Nuxt.js

Add module to nuxt.config.js

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

Usage

DruxtMenu component

The DruxtMenu component intelligently loads in your Drupal menu using the built-in JSON:API as well as the Drupal JSON:API Menu Items module.

<DruxtMenu name="main" :depth="1" />

Example DruxtMenu component

See the DruxtMenu API Documentation for more information.

Theming

The DruxtMenu component can be themed by providing a default template:

<DruxtMenu name="main">
  <template #default="{ items }">
    {{ items }}
  </template>
</DruxtMenu>

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

<template>
  <div>
    <slot />
  <div>
</template>

See the Druxt Theming guide for more information.

Options

Druxt Menu options

These options are specific to this module.

OptionTypeRequiredDefaultDescription
menu.jsonApiMenuItemsbooleanNotrueUse the Drupal JSON:API Menu Items module resource.
menu.query.fieldsstring[]NofalseAn array of fields to filter all JSON:API Menu queries.
menu.query.requiredOnlybooleanNofalseWhether to automatically filter to module-defined minimum required fields.

Base 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.

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