API Documentation

DruxtRouter

router

Modules

DruxtRouter

The DruxtRouter component renders a Drupal decoupled route, or path, using the appropriate Druxt component.

For instance, using the path /node/1 would render a DruxtEntity component.

The Vue router path will be used if not path is defined.

Typedefs

ComponentOptions : Array.<array>

Provides the available naming options for the Wrapper component.

PropsData : object

Provides property data for use in the Wrapper component.

ScopedSlots : object

Provides scoped slots for use in the Wrapper component.

DruxtRouter

The DruxtRouter component renders a Drupal decoupled route, or path, using the appropriate Druxt component.

For instance, using the path /node/1 would render a DruxtEntity component.

The Vue router path will be used if not path is defined.

Example (Render using the Vue router path)

<DruxtRouter />

Example (Render a specified path)

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

Example (Render the result of the model, bypasses Drupal backend)

<DruxtRouter v-model="route" />

Example (DruxtRouter Wrapper component boilerplate)

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

<script>
import { DruxtRouterMixin } from 'druxt-router'
export default {
  mixins: [DruxtRouterMixin]
}

Example (DruxtRouter with template injection)

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

.props

Kind: static property of DruxtRouter


.path : string

The Decoupled router path.

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

Kind: static property of props
Example

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

.value : object

The Router object, used to determine the resolved route component.

Setting this value will bypass the JSON:API.

Kind: static property of props
Model:


.computed

Kind: static property of DruxtRouter


.module : string

The route module.

Kind: static property of computed


.route : object

The route object.

Kind: static property of computed


.title : boolean | string

Route title.

Kind: static property of computed
Default: false


.props : object | string

Route component property data.

Kind: static property of computed
Default: false


.watch

Kind: static property of DruxtRouter


.path()

Re-fetch on update to Path prop.

Kind: static method of watch


.druxt

DruxtModule settings

Kind: static property of DruxtRouter


.componentOptions(context) ⇒ ComponentOptions

Provides the available component naming options for the Druxt Wrapper.

Kind: static method of druxt

ParamTypeDescription
contextobjectThe module component ViewModel.

.fetchConfig()

Fetch the decoupled route.

Kind: static method of druxt


.propsData(context) ⇒ PropsData

Provides propsData for the DruxtWrapper.

Kind: static method of druxt

ParamTypeDescription
contextobjectThe module component ViewModel.

.slots() ⇒ ScopedSlots

Provides the scoped slots object for the Module render function.

  • debug: A Debug component with a Path override field.
  • default: Default error handling.

Kind: static method of druxt
Returns: ScopedSlots - The Scoped slots object.
Example (DruxtRouterModule.vue)

<template>
  <div>
    <slot name="debug" />
    {{ route.props }}
  </div>
</template>

.middleware()

Nuxt middleware; gets and sets the current route, and processes redirects.

This can be disabled by setting the druxt.router.middleware option to false in nuxt.config.js

Kind: static method of DruxtRouter
Example

export default {
  druxt: {
    router: {
      middleware: false
    }
  }
}

.data()

Kind: static method of DruxtRouter
Properties

NameTypeDescription
modelobjectThe model object.

Nuxt head method.

  • Sets the page title.
  • Sets the canonical link.

Kind: static method of DruxtRouter
Todo

  • Improve metatag support.

ComponentOptions : Array.<array>

Provides the available naming options for the Wrapper component.

Kind: global typedef
Example

[
  'DruxtRouter[Module][IsFront?][Langcode]',
  'DruxtRouter[Module][IsFront?]',
  'DruxtRouter[Module][Langcode]',
  'DruxtRouter[Module]',
  'DruxtRouter[Default][Langcode]',
  'DruxtRouter[Default]',
]

Example (Entity route)

[
  'DruxtRouterEntityFrontEn',
  'DruxtRouterEntityFront',
  'DruxtRouterEntityEn',
  'DruxtRouterEntity',
  'DruxtRouterDefaultEn',
  'DruxtRouterDefault'
]

PropsData : object

Provides property data for use in the Wrapper component.

Kind: global typedef

ParamTypeDescription
pathstringThe route path.
routeobjectThe Decoupled Router object.

Example

{
  path: '/',
  route: {
    canonical: 'https://demo-api.druxtjs.org/en/node',
    component: 'druxt-view',
    error: false,
    isHomePath: true,
    jsonapi: {},
    label: 'Home',
    props: {},
    redirect: false,
    resolvedPath: '/en/node',
    type: 'views',
  }
}

ScopedSlots : object

Provides scoped slots for use in the Wrapper component.

Kind: global typedef

ParamTypeDescription
debugfunctionA Debug component with a Path override field.
defaultfunctionDefault error handling.

Example (DruxtRouterModule.vue)

<template>
  <div>
    <slot name="debug" />
    {{ route.props }}
  </div>
</template>