Skip to content

Render a breadcrumb trail in Nuxt from the Drupal decoupled router, with the DruxtBreadcrumb component and its theming options.

DruxtBreadcrumb

View source on GitHub

DruxtBreadcrumb

The DruxtBreadcrumb component renders a list of breadcrumbs based on the active route.

Example

<DruxtBreadcrumb />

Example

<DruxtBreadcrumb path="/node/1" />

Example (DruxtBreadcrumb Wrapper component boilerplate)

<template>
  <DruxtDebug :json="crumbs" />
</template>

<script>
import { DruxtBreadcrumbMixin } from 'druxt-breadcrumb'
export default {
  mixins: [DruxtBreadcrumbMixin]
}
</script>

Example (DruxtBreadcrumb default slot (template injection))

<DruxtBreadcrumb>
  <template #default="{ crumbs }">
    <!-- Do whatever you want here -->
    <DruxtDebug :json="crumbs" />
  </template>
</DruxtBreadcrumb>

.fetchCrumbs()

Fetch Crumbs

Kind: instance method of DruxtBreadcrumb


.error(err, [context])

Sets the component to render a DruxtDebug error message.

Kind: instance method of DruxtBreadcrumb

ParamTypeDescription
errobjectThe error object.
[context]objectError context; carries the wrapper component data where the failure knows it.

.getModuleComponents() ⇒ Components

Get list of module wrapper components.

Kind: instance method of DruxtBreadcrumb


.getModulePropsData(wrapperProps) ⇒ object

Get module propsData via modules druxt.propsData() callback.

Kind: instance method of DruxtBreadcrumb

ParamTypeDescription
wrapperPropsobjectProps registered by the Wrapper component.

Example

{
  $attrs: { entity: {}, fields: {}, langcode: 'en', schema: {} },
  props: { value: {} },
  propsData: { entity: {}, fields: {}, langcode: 'en', schema: {}, value: {} },
}

.getScopedSlots() ⇒ object

Gets a Druxt modules scoped slots, and if there's no default slots, provides a develop mode debug default or passes through to a default template.

Kind: instance method of DruxtBreadcrumb


.getWrapperData(component) ⇒ WrapperData

Get wrapper component data.

Kind: instance method of DruxtBreadcrumb

ParamTypeDescription
componentstringThe Wrapper component name.

.props

Kind: static property of DruxtBreadcrumb


.home : boolean

Show home crumb?

Kind: static property of props
Default: true
Example

<DruxtBreadcrumb :home="false" />

.path : string

The Decoupled router path.

If not set, the Vue router value will be used instead.

Kind: static property of props
Example

<DruxtBreadcrumb path="/node/1" />

.langcode : string

The resource langcode.

Kind: static property of props
Example

@lang vue
<DruxtBreadcrumb langcode="en" />

.v-model : mixed

The Vue.js v-model binding for the module.

Setting a value provides the module data directly, so the Drupal JSON:API fetch is skipped.

Kind: static property of props
Default:
Example

@lang vue
<template>
  <DruxtBreadcrumb v-model="model" />
</template>

<script>
export default {
  data: () => ({ model: { foo: 'bar' } })
}
</script>

.wrapper : (boolean | object)

The wrapper component configuration.

Used to set the wrapper component, class, style and propsData.

Kind: static property of props
Default: () => undefined
Example

<DruxtBreadcrumb
  :wrapper="{
    component: 'BCard',
    class: 'article-card',
    propsData: { noBody: true }
  }"
/>

.computed

Kind: static property of DruxtBreadcrumb


.crumbs

Kind: static property of computed

ParamTypeDescription
vmobjectThe component ViewModel.
vm.modelArray.<object>The Breadcrumbs model value.

Properties

NameTypeDescription
crumbsArray.<objects>The Breadcrumbs.

.watch

Kind: static property of DruxtBreadcrumb


.$route()

Updates crumbs on Route change.

Kind: static method of watch


.druxt

DruxtModule settings

Kind: static property of DruxtBreadcrumb


.template

Druxt development template tool configuration.

Kind: static property of druxt


.componentOptions() ⇒ ComponentOptions

Provides the available component naming options for the Druxt Wrapper.

Kind: static method of druxt


.fetchConfig()

Fetches the breadcrumbs.

Kind: static method of druxt


.propsData(context) ⇒ PropsData

Provides propsData for the DruxtWrapper.

Kind: static method of druxt

ParamTypeDescription
contextobjectThe module component ViewModel.
context.modelArray.<object>The Breadcrumbs model value.

.slots() ⇒ ScopedSlots

Provides the scoped slots object for the Module render function.

The default slot renders crumbs as a list of NuxtLink's.

Kind: static method of druxt
Returns: ScopedSlots - The Scoped slots object.


.methods

Kind: static property of DruxtBreadcrumb


.data(vm)

Kind: static method of DruxtBreadcrumb

ParamTypeDescription
vmobjectThe component ViewModel.
vm.value*The module component model value.

Properties

NameTypeDescription
componentComponentDataThe wrapper component and propsData to be rendered.
model*The module component model value.

.fetch()

Loads the Druxt module data and applies a wrapper component as required.

Important: If your component has an existing fetch method, you must manually invoke the DruxtModule.fetch() hook.

Kind: static method of DruxtBreadcrumb
Example (Manually invoking DruxtModule.fetch().)

import DruxtModule from 'druxt/components/DruxtModule.vue'
export default {
  name: 'DruxtCustomModule',
  extends: DruxtModule,
  async fetch() {
    await DruxtModule.fetch.call(this)
  },
  druxt: {
    componentOptions: () => ([['Default']]),
    propsData: ({ model }) => ({ value: model }),
  }
}

.lang(vm) ⇒ string

The current language code: the langcode prop if set, otherwise the route's langcode metadata.

Used by Druxt modules to fetch the correct resource translation.

Kind: static method of DruxtBreadcrumb
Returns: string - The current language code.

ParamTypeDescription
vmobjectThe component ViewModel.
vm.langcodestringThe langcode prop.
vm.$routeobjectThe current route.

ComponentOptions : Array.<array>

Provides the available naming options for the Wrapper component.

Kind: global typedef
Example

[
  'DruxtBreadcrumb[Default][Langcode]',
  'DruxtBreadcrumb[Default]',
]

Example

[
  'DruxtBreadcrumbDefaultEn',
  'DruxtBreadcrumbDefault',
]

PropsData : object

Provides propsData for use in the Wrapper component.

Kind: global typedef

ParamTypeDescription
crumbsArray.<objects>The Breadcrumbs.
valueArray.<objects>The Breadcrumbs value.

Example

{
  crumbs: [{
    text: 'Home',
    to: '/',
  }],
  value: [{
    text: 'Home',
    to: '/',
  }],
}

ScopedSlots : object

Provides scoped slots for use in the Wrapper component.

Kind: global typedef

ParamTypeDescription
defaultfunctionCrumbs as a list of NuxtLink's.

Example (DruxtBreadcrumbDefault.vue)

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

Inherited type definitions

Inherited from DruxtModule: ComponentData, Components, WrapperData.