Drupal router for Nuxt, powered by the Drupal Decoupled Router module.
DruxtRouter connects Nuxt routing to Drupal routing. A wildcard route catches
requests, resolves them through Drupal's
Decoupled Router with path
aliases and redirects included, and renders the matching Druxt component for
the resolved entity or view. Your Nuxt pages/ directory keeps working
alongside it, so a custom page can take over any route.
Features
- Vue.js components:
- DruxtRouter: Renders a Druxt component for the resolved Decoupled route
- Route providers:
- Content entity routes resolve DruxtEntity components
- Drupal Views page routes resolve DruxtView components
Installation
-
Install the package:
npm i druxt-router -
Add the module to
nuxt.config.js:export default { modules: ['druxt-router/nuxt'], };
Options
-
druxt.router.middlewareType:
boolean
Default:trueControls whether to execute the Route page middleware and process redirects.
-
druxt.router.pagesType:
boolean
Default:trueif pages/ directory exists, elsefalseControls whether the Nuxt pages/ directory is used to generate routes.
-
druxt.router.wildcardType:
boolean
Default:trueControls whether the wildcard route should be installed into the Nuxt/Vue router.
Vue.js components
DruxtRouter
Renders a Druxt module router component based on the resolved route provided by the Drupal Decoupled Router module.
<DruxtRouter path="/" />
If no Path is provided, the component will default to the Vue router fullpath.
- For more details, refer to the DruxtRouter API documentation.
Deprecations
Retired DruxtRouter client pass-through methods and druxtRouter store
resource members, with their replacements, are listed on the
deprecations page.
- For the routing API itself, see the DruxtRouter API documentation.
Options
Druxt Router options
These options are specific to this module.
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
router.middleware | boolean | No | true | Whether to run the Route page middleware and redirects. |
router.pages | boolean | No | true if pages/ exists | Whether to parse the Nuxt pages/ directory. |
router.wildcard | boolean | No | true | Whether to install the wildcard route. |
Base Druxt options
These options are available to all DruxtJS modules.
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
axios | object | No | {} | Axios instance settings. |
baseUrl | string | Yes | null | Base URL for the Drupal installation. |
endpoint | string | No | /jsonapi | JSON:API Endpoint of the Drupal installation. |
Note: The contents of this file were automatically generated from the packages/router/README.md.