diff --git a/README.md b/README.md index a095884..2c4f908 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Set these properties within `cloak: { craft: { ... } }` in the nuxt.config.js: - `pageTypenames` - An array of GraphQL typenames of Craft entry types whose URIs should be generated as pages. For example: `['towers_tower_Entry']`. Defaults to `[]`. - `generateRedirects` - If true, adds redirect to the `static/_redirects` file using a `redirects` Craft section. - `mocks` - An array of objects for use with [`mockAxiosGql`](https://github.com/BKWLD/cloak-utils/blob/main/src/axios.js). +- `injectClient` - Boolean for whether to inject the `$craft` client globally. Defaults to `true`. You would set this to `false` when this module is a depedency of another module (like [@cloak-app/algolia](https://github.com/BKWLD/cloak-algolia)) that is creating `$craft` a different way. ## Usage diff --git a/nuxt.js b/nuxt.js index 9428f9d..bdf7060 100644 --- a/nuxt.js +++ b/nuxt.js @@ -14,6 +14,7 @@ export default function() { setDefaultOptions(this, 'craft', { generateRedirects: false, pageTypenames: [], + injectClient: true, }) // Set default options @@ -34,7 +35,9 @@ export default function() { // Add the Craft plugin which creates the Craft instance of Axios. Not using // this.addPlugin so I don't have to deal with adding sub-imports via // addTemplate. - this.options.plugins.unshift(join(__dirname, 'plugins/craft-client.js')) + if (this.options.cloak.craft.injectClient) { + this.options.plugins.unshift(join(__dirname, 'plugins/craft-client.js')) + } // Support mocking requireOnce(this, join(__dirname, './modules/mock-craft.js'))