drunomics / nuxtjs-drupal-ce

A Nuxt module to easily connect Drupal via custom elements.
https://lupus-decoupled.org/
MIT License
22 stars 4 forks source link
drupal nuxt-module

nuxtjs-drupal-ce - Nuxt.js Drupal Custom Elements Connector

npm version npm downloads ci codecov License

Connects Nuxt v3 with Drupal via the Lupus Custom Elements Renderer

Please refer to https://www.drupal.org/project/lupus_decoupled for more info.

The 2.x version of the module is compatible with Nuxt 3. For a Nuxt 2 compatible version, please checkout the 1.x version

Pre-requisites

Setup

  1. Add nuxtjs-drupal-ce dependency to your Nuxt project
yarn add nuxtjs-drupal-ce@beta # or npm install nuxtjs-drupal-ce@beta
  1. Add nuxtjs-drupal-ce to the modules section of nuxt.config.js
export default defineNuxtConfig({
  modules: [
    'nuxtjs-drupal-ce',
  ],
  drupalCe: {
    drupalBaseUrl: 'https://your-drupal.example.com',
    // more options...
  }
})

The module defaults work well with Lupus Decoupled Drupal - in that case setting the drupalBaseUrl is enough to get started.

  1. Get started quickly by scaffolding initial files:
    rm -f app.vue && npx nuxt-drupal-ce-init

Features

Options

Overriding options with environment variables

Runtime config values can be overridden with environment variables via NUXT_PUBLIC_ prefix. Supported runtime overrides:

Deprecated options

The following options are deprecated and only there for improved backwards compatibility.

Error handling

The module provides a default error handler for the fetchPage and fetchMenu methods:

Customizing error handling

You have the option to override the default error handlers by using a parameter when calling the fetch methods.

Note: The error parameter is optional and can be omitted.

Previous options not supported in 2.x version

The following options were support in 1.x but got dropped:

Development

  1. Clone this repository.
  2. Install dependencies using npm install.
  3. Run npm run dev:prepare to generate type stubs.
  4. Use npm run dev to start playground in development mode.
  5. Update baseURL setting in Nuxt config with Lupus Decoupled Drupal instance URL and append the API-prefix /ce-api, e.g. https://8080-shaal-drupalpod-8m3z0ms7mb6.ws-eu67.gitpod.io/ce-api

Run on StackBlitz

  1. Launch it on StackBlitz
  2. Update baseURL setting in Nuxt config with Lupus Decoupled Drupal instance URL and append the API-prefix /ce-api, e.g. https://8080-shaal-drupalpod-8m3z0ms7mb6.ws-eu67.gitpod.io/ce-api

License

MIT License

Credits

Development sponsored by drunomics hello@drunomics.com