API Documentation
DruxtMenu
Modules
- DruxtMenu
The DruxtMenu component renders a Drupal menu using either the default Drupal content menus, or the full menu via the JSON:API Menu Items module.
Typedefs
- ComponentOptions :
Array.<array>
Provides the available naming options for the Wrapper component.
- ModuleSettings :
object
Provides settings for the Menu module, via the
nuxt.config.js
druxt.menu
or the Wrapper componentdruxt
object.- PropsData :
object
Provides propsData for use in the Wrapper component.
- ScopedSlots :
object
Provides scoped slots for use in the Wrapper component.
DruxtMenu
The DruxtMenu component renders a Drupal menu using either the default Drupal content menus, or the full menu via the JSON:API Menu Items module.
Example
<DruxtMenu name="main" />
Example (DruxtMenu Wrapper component boilerplate)
<template>
<DruxtDebug :json="items" />
</template>
<script>
import { DruxtMenuMixin } from 'druxt-menu'
export default {
mixins: [DruxtMenuMixin]
}
Example (DruxtMenu with template injection)
<DruxtMenu>
<template #default="{ items }">
<!-- Do whatever you want here -->
<DruxtDebug :json="items" />
</template>
</DruxtMenu>
- DruxtMenu
- instance
- static
- .props
- .depth :
number
- .itemClass :
string
- .itemComponent :
string
- .maxDepth :
number
- .minDepth :
number
- .name :
string
- .parentId :
string
- .parentClass :
string
- .parentComponent :
string
- .parentWrapperClass :
string
- .parentWrapperComponent :
string
- .langcode
- .v-model
- .wrapper
- .depth :
- .computed
- .watch
- .druxt
- .props
.getMenuItems([entity], [position])
Recursively gets required menu items from the Vuex store.
Kind: instance method of DruxtMenu
Param | Type | Description |
---|---|---|
[entity] | object | Current menu item entity. |
[position] | number | Current position in the menu tree, |
.props
Kind: static property of DruxtMenu
- .props
- .depth :
number
- .itemClass :
string
- .itemComponent :
string
- .maxDepth :
number
- .minDepth :
number
- .name :
string
- .parentId :
string
- .parentClass :
string
- .parentComponent :
string
- .parentWrapperClass :
string
- .parentWrapperComponent :
string
- .langcode
- .v-model
- .wrapper
- .depth :
number
.depth : The depth of the menu items to render.
Kind: static property of props
Default: 0
Example
<DruxtMenu :depth="1" />
string
.itemClass : Class(es) to apply to the menu items.
Kind: static property of props
string
.itemComponent : Component or element to render the menu items.
Kind: static property of props
Default: "li"
number
.maxDepth : The maximum depth of the menu tree data to load.
Kind: static property of props
Example
<DruxtMenu :max-depth="4" />
number
.minDepth : The minimum depth of the menu tree.
Kind: static property of props
Default: 0
Example
<DruxtMenu :min-depth="2" />
string
.name : The name of the menu to load and render.
Kind: static property of props
Default: "main"
Example
<DruxtMenu name="main" />
string
.parentId : The menu parent ID to use as the root of the menu.
Kind: static property of props
Example
<DruxtMenu parent-id="views_view:views.recipes.page_1" />
string
.parentClass : Class(es) to apply to parent menu items.
Kind: static property of props
string
.parentComponent : Component or element to render parent menu items.
Kind: static property of props
Default: "li"
string
.parentWrapperClass : Class(es) to apply to a wrapper around parent menu items.
Kind: static property of props
string
.parentWrapperComponent : Component or element to render a wrapper around parent menu items.
Kind: static property of props
Default: "ul"
.langcode
The resource langcode.
Kind: static property of props
Example
<DruxtMenu langcode="en" />
.v-model
The module component model value.
Used to bypass the Drupal JSON:API fetch, setting the module data directly.
Kind: static property of props
Example
<DruxtMenu v-model="{ foo: bar }" />
.wrapper
The wrapper component configuration.
Used to set the wrapper component, class, style and propsData.
Kind: static property of props
Example
<DruxtMenu
:wrapper="{
component: 'MyWrapper',
class: 'wrapper',
propsData: { foo: 'bar' }
}"
/>
.computed
Kind: static property of DruxtMenu
.items : Array.<objects>
Array.<objects>
Deprecated
The processed Menu items.
Kind: static property of computed
Array.<string>
.trail : The active route trail.
Kind: static property of computed
.watch
Kind: static property of DruxtMenu
.entities()
Updates menu when available Entities change.
Kind: static method of watch
.druxt
DruxtModule settings.
Kind: static property of DruxtMenu
.template
Druxt development template tool configuration.
Kind: static property of druxt
ComponentOptions
.componentOptions(context) ⇒ Provides the available component naming options for the Druxt Wrapper.
Kind: static method of druxt
Param | Type | Description |
---|---|---|
context | object | The module component ViewModel. |
.fetchData()
Builds and executes the JSON:API query, loading the menu items into the druxtMenu Vuex store.
Kind: static method of druxt
PropsData
.propsData(context) ⇒ Provides propsData for the DruxtWrapper.
Kind: static method of druxt
Param | Type | Description |
---|---|---|
context | object | The module component ViewModel. |
.settings()
Component settings.
Kind: static method of druxt
ScopedSlots
.slots() ⇒ Provides the scoped slots object for the Module render function.
Adds a default
slot that will render the menu tree using the
DruxtMenuItem component.
Kind: static method of druxt
Returns: ScopedSlots
- The Scoped slots object.
Example (DruxtMenuName.vue)
<template>
<div>
<slot />
</div>
</template>
Array.<array>
ComponentOptions : Provides the available naming options for the Wrapper component.
Kind: global typedef
Example
[
'DruxtMenu[Name][Langcode]',
'DruxtMenu[Name]',
'DruxtMenu[Default][Langcode]',
'DruxtMenu[Default]',
]
Example (Main menu (default))
[
'DruxtMenuMainEn',
'DruxtMenuMain',
'DruxtMenuDefaultEn',
'DruxtMenuDefault',
]
object
ModuleSettings : Provides settings for the Menu module, via the nuxt.config.js
druxt.menu
or the Wrapper component druxt
object.
Kind: global typedef
Param | Type | Description |
---|---|---|
fields | Array.<string> | An array of fields to filter all JSON:API Menu queries. |
requiredOnly | boolean | Whether to automatically filter to module defined minimum required fields. |
Example
{
fields: [],
requiredOnly: true,
}
Example
<script>
export default {
druxt: {
query: {
fields: ['description', 'options']
requiredOnly: false,
},
}
}
object
PropsData : Provides propsData for use in the Wrapper component.
Kind: global typedef
Param | Type | Description |
---|---|---|
items | Array.<object> | The Menu items structured data. |
value | Array.<object> | The Menu items structured data. |
Example
{
items: [
{
children: [],
entity: {},
},
],
value: [
{
children: [],
entity: {},
},
],
}
object
ScopedSlots : Provides scoped slots for use in the Wrapper component.
Kind: global typedef
Param | Type | Description |
---|---|---|
default | function | All menu items using the DruxtMenuItem component |
Example (DruxtMenuName.vue)
<template>
<div>
<slot />
</div>
</template>