API Documentation
DruxtBlock
Modules
- DruxtBlock
The DruxtBlock component is used to render a Drupal Block by UUID or Drupal's internal ID.
While the DruxtBlock component can't automatically render every Drupal block, it does provide the Block settings to a targetted Druxt wrapper component for manual theming.
Typedefs
- ComponentOptions :
Array.<array> Provides the available naming options for the Wrapper component.
- ModuleSettings :
object Provides settings for the Blocks module, via the
nuxt.config.jsdruxt.blocksobject.- PropsData :
object Provides propsData for use in the Wrapper component.
- ScopedSlots :
object Provides scoped slots for use in the Wrapper component.
DruxtBlock
The DruxtBlock component is used to render a Drupal Block by UUID or Drupal's internal ID.
While the DruxtBlock component can't automatically render every Drupal block, it does provide the Block settings to a targetted Druxt wrapper component for manual theming.
Example (Render a block using id)
<DruxtBlock id="umami_branding" />
Example (Render a block using uuid)
<DruxtBlock uuid="59104acd-88e1-43c3-bd5f-35800f206394" />
Example (DruxtBlock Wrapper component boilerplate)
<template>
<DruxtDebug :json="block" />
</template>
<script>
import { DruxtBlocksBlockMixin } from 'druxt-blocks'
export default {
mixins: [DruxtBlocksBlockMixin]
}
Example (DruxtBlock with template injection)
<DruxtBlock id="umami_branding">
<template #default="{ block }">
<!-- Do whatever you want here -->
<DruxtDebug :json="block" />
</template>
</DruxtBlock>
.props
The DruxtBlock component requires either the UUID or internal ID property.
Kind: static property of DruxtBlock
.id : string
The Blocks internal ID.
Kind: static property of props
Example
<DruxtBlock id="umami_branding" />
.uuid : string
The Block Entity UUID.
If used, the id prop will be ignored.
Kind: static property of props
Example
<DruxtBlock uuid="59104acd-88e1-43c3-bd5f-35800f206394" />
.langcode
The resource langcode.
Kind: static property of props
Example
<DruxtBlock 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
<DruxtBlock 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
<DruxtBlock
:wrapper="{
component: 'MyWrapper',
class: 'wrapper',
propsData: { foo: 'bar' }
}"
/>
.computed
Kind: static property of DruxtBlock
.block ⇒ object
The Block entity data.
Kind: static property of computed
.druxt
Druxt module configuration.
Kind: static property of DruxtBlock
.template
Druxt development template tool configuration.
Kind: static property of druxt
.componentOptions(context) ⇒ ComponentOptions
Provides the available component naming options for the DruxtWrapper.
Kind: static method of druxt
| Param | Type | Description |
|---|---|---|
| context | object | The module component ViewModel. |
.fetchConfig()
Fetches the Block JSON:API resource by either UUID or ID.
Kind: static method of druxt
.propsData(context) ⇒ PropsData
Provides propsData for the DruxtWrapper.
Kind: static method of druxt
| Param | Type | Description |
|---|---|---|
| context | object | The module component ViewModel. |
.slots() ⇒ ScopedSlots
Provides the scoped slots object for the Module render function.
A default slot is provided with debug information if Nuxt is in development mode.
Kind: static method of druxt
Returns: ScopedSlots - The Scoped slots object.
.data()
Kind: static method of DruxtBlock
Properties
| Name | Type | Description |
|---|---|---|
| resource | object | The JSON:API resource object. |
ComponentOptions : Array.<array>
Provides the available naming options for the Wrapper component.
Kind: global typedef
Example
[
'DruxtBlock[Plugin][PluginId][Region][Theme][Langcode]',
'DruxtBlock[Plugin][PluginId][Region][Theme]',
'DruxtBlock[Plugin][PluginId][Theme][Langcode]',
'DruxtBlock[Plugin][PluginId][Theme]',
'DruxtBlock[Plugin][Region][Theme][Langcode]',
'DruxtBlock[Plugin][Region][Theme]',
'DruxtBlock[Plugin][Theme][Langcode]',
'DruxtBlock[Plugin][Theme]',
'DruxtBlock[Default][Langcode]',
'DruxtBlock[Default]',
]
Example (Umami Branding block)
[
'DruxtBlockSystemBrandingBlockHeaderUmamiEn',
'DruxtBlockSystemBrandingBlockHeaderUmami',
'DruxtBlockSystemBrandingBlockHeaderEn',
'DruxtBlockSystemBrandingBlockHeader',
'DruxtBlockSystemBrandingBlockUmamiEn',
'DruxtBlockSystemBrandingBlockUmami',
'DruxtBlockSystemBrandingBlockEn',
'DruxtBlockSystemBrandingBlock',
'DruxtBlockDefaultEn',
'DruxtBlockDefault',
]
ModuleSettings : object
Provides settings for the Blocks module, via the nuxt.config.js
druxt.blocks object.
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| fields | Array.<string> | An array of fields to filter from the JSON:API Resource. |
Example
{
fields: [],
}
Example (nuxt.config.js)
export default {
druxt: {
blocks: {
query: {
fields: ['dependencies'],
},
},
},
}
PropsData : object
Provides propsData for use in the Wrapper component.
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| block | object | The Block Entity data. |
Example
{
block: {
attributes: {},
id: '59104acd-88e1-43c3-bd5f-35800f206394',
links: {},
relationships: {},
type: 'block--block',
},
}
ScopedSlots : object
Provides scoped slots for use in the Wrapper component.
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| default | function | Debug information if Nuxt is in development mode. |