API Documentation
DruxtRouter
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
string
.path : 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" />
object
.value : The Router object, used to determine the resolved route component.
Setting this value will bypass the JSON:API.
Kind: static property of props
Model:
.langcode
The resource langcode.
Kind: static property of props
Example
<DruxtRouter langcode="en" />
.v-model
The Router object, used to determine the resolved route component.
Setting this value will bypass the JSON:API.
Kind: static property of props
.wrapper
The wrapper component configuration.
Used to set the wrapper component, class, style and propsData.
Kind: static property of props
Example
<DruxtRouter
:wrapper="{
component: 'MyWrapper',
class: 'wrapper',
propsData: { foo: 'bar' }
}"
/>
.computed
Kind: static property of DruxtRouter
string
.module : The route module.
Kind: static property of computed
object
.route : The route object.
Kind: static property of computed
boolean
| string
.title : Route title.
Kind: static property of computed
Default: false
object
| string
.props : 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
.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. |
.fetchConfig()
Fetch the decoupled route.
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. |
ScopedSlots
.slots() ⇒ 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
Name | Type | Description |
---|---|---|
model | object | The model object. |
.head()
Nuxt head method.
- Sets the page title.
- Sets the canonical link.
Kind: static method of DruxtRouter
Todo
- Improve metatag support.
Array.<array>
ComponentOptions : 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'
]
object
PropsData : Provides property data for use in the Wrapper component.
Kind: global typedef
Param | Type | Description |
---|---|---|
path | string | The route path. |
route | object | The 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',
}
}
object
ScopedSlots : Provides scoped slots for use in the Wrapper component.
Kind: global typedef
Param | Type | Description |
---|---|---|
debug | function | A Debug component with a Path override field. |
default | function | Default error handling. |
Example (DruxtRouterModule.vue)
<template>
<div>
<slot name="debug" />
{{ route.props }}
</div>
</template>