DruxtNuxtModule
DruxtNuxtModule(moduleOptions)
Nuxt module function to install Druxt.
Kind: global function
| Param | Type | Description |
|---|---|---|
| moduleOptions | ModuleOptions | DruxtJS module options. |
Example (Nuxt configuration with module options)
module.exports = {
modules: [
['druxt', { baseUrl: 'https://api.umami.demo.druxtjs.org' }]
]
}
Example (Nuxt configuration with root level options)
module.exports = {
modules: [
'druxt'
],
druxt: {
baseUrl: 'https://api.umami.demo.druxtjs.org'
}
}
ModuleOptions : object
Module options object.
Kind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| baseUrl | string | The Base URL of the Drupal JSON:API backend. | |
| [endpoint] | string | "/jsonapi" | The JSON:API endpoint path. |
| [proxy] | object | Proxy settings object. | |
| [proxy.api] | boolean | Proxy the JSON:API. | |
| [proxy.files] | boolean | string | Proxy Drupal's site files directory. Provide String to specify multi-site path. | |
| [cache] | object | boolean | Server-side cache of the JSON:API index and menus, and with cache.content every other response, shared between requests that do not send an Authorization header, basic auth or a session cookie. Each response is kept for as long as Drupal's Cache-Control header allows, which is never on a site whose page cache max-age is 0. Off under nuxt dev. false turns it off. | |
| [cache.content] | boolean | false | Also keep entities, collections, views and route lookups, under the same rules. Pair it with a clear from Drupal, as content changes far more often than menus. |
| [cache.maxSize] | number | 52428800 | Bytes of responses each cache area keeps, measured as stored JSON. Past it the least recently used go first, and a response larger than the limit is not kept. |
| [cache.ttl] | number | Seconds a cached response may live at most. It shortens Drupal's lifetime, never extends it. | |
| [cache.secret] | string | Turns on POST /_druxt/cache/clear, which empties the cache when the X-Druxt-Secret header matches. It stays on the server and is never sent to the browser. | |
| [cache.sessionCookie] | string | "S?SESS[0-9a-f]+" | A pattern for the name of the backend's session cookie. A request with a matching cookie never uses the cache. |
Example
export default {
modules: ['druxt'],
druxt: {
baseUrl: 'https://api.umami.demo.druxtjs.org',
endpoint: '/jsonapi',
proxy: {
api: true,
files: 'default'
}
}
}